Debug your code and put a breakpoint on the line
XElement el = XNode.ReadFrom(reader) as XElement;
When the code reaches that point for the first time, hover over the variable
reader
and you will notice that it has the name "Text" - what you would expect!
Now F10 over the breakpoint and hover over
reader
again ... now you see that reader has the name "rulein" ... in other words that line has move the xmlreader further through the file ... it is no longer "pointing" at the line you think it is... so the line
else if (reader.Name == "rulein")
will skip straight over the node rulein.
Try removing the
else
i.e. use
if (reader.Name == "rulein")
... carry on stepping through the code and you will see that it will now drop into that
if
statement and handle "rulein"
Note, the same problem will arise with
else if (child.Name == "truefalse")
- get rid of the else.
Have a look at this example
http://www.dotnetperls.com/xmlreader[
^] of a simple use of xmlreader
without using
XElement