XmlTextReader - Child elements.
-
Hi All, I am reading Xml data using XmlTextReader on a file stream. I read the elements and the element attributes with no problem but I can't figure out how to identify if the current element has further child elements or is finalized (ends with />). I can handle (the reader.Read() shows 'Element' (with 2 attributes) then EndElement - no problem) I have problems with ; (the reader.Read() shows 'Element' (with 2 attributes) then the next element) In the second case I can't figure out if the next element is a child element or not. Or to be more precise I don't know when the original element ends. Thanks.
-
Hi All, I am reading Xml data using XmlTextReader on a file stream. I read the elements and the element attributes with no problem but I can't figure out how to identify if the current element has further child elements or is finalized (ends with />). I can handle (the reader.Read() shows 'Element' (with 2 attributes) then EndElement - no problem) I have problems with ; (the reader.Read() shows 'Element' (with 2 attributes) then the next element) In the second case I can't figure out if the next element is a child element or not. Or to be more precise I don't know when the original element ends. Thanks.
Why not just load the entire document into an XmlDocument instead?? Then you can get all the child element collection information you want?
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
Why not just load the entire document into an XmlDocument instead?? Then you can get all the child element collection information you want?
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
Thanks for that. That's what I've now done. Works fine. I just thought there would have to be some sort of 'HasEndElement' type property for an Element node on the XmlTextReader.Read Element. Cheers. :)
Since the Reader hasn't gotten that far, there's no way for it to tell...
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008