Wednesday 23 October 2013

xmlReader.Read() skipping nodes xmlReader.ReadOuterXml()


XMLReader.Read() is strange behaviour when I try to parse XML using the XmlReader object. It usually skips the record and move the pointer to next level of element while loop through the elements. The code which I used to find each child records.

This is the sample xml file.











The code which I used to find each child records as detailed below.

When you call ReadOuterXml() method this would consume the complete xml  and point the cursor to just before the next element.

In my example the cursor will pint to element of Order ID=2 record. Hence it never satisfies the condition to fetch Record 2.




Here is the alternate way to find the child records.


You can reach me @ raj.webjunky@Yahoo.com




No comments:

Post a Comment