0

I'm reading through a large XML file and parsing it into HTML.

My current challenge is that child nodes can contain information regarding its parent. If you look at the code below, the panel is its own XML node and can contain XML attributes that describe its styling. However, it can have nested child elements that contains event information.

I am using .Net XmlTextReader to read the XML. Is there a clever way to loop and read this node's child elements so I can easily add additional HTML attributes to this tag element?

<Panel x="20" y="40">
  <State type="Release" fontCol="4294967295">
    <Action action="Close" id="eid-6" />
  </State>
  <State type="Pressed" fontCol="4294967295" />
  <State type="Hold" fontCol="4294967295" />
</panel>
RyanS
  • 627
  • 1
  • 10
  • 26
Andrew Nielsen
  • 113
  • 1
  • 8
  • 1
    If you're file's too big to use LINQ to XML on it (which would be *a lot* easier), you can use a hybrid approach such as that outlined in the answer to [this question](http://stackoverflow.com/questions/2441673/reading-xml-with-xmlreader-in-c-sharp) – Charles Mager Nov 20 '15 at 19:27
  • If you want to scan through the child elements of an element without loading them all into memory, and you're concerned about reading past the end of the element, you can use [`XmlReader.ReadSubtree()`](https://msdn.microsoft.com/en-us/library/system.xml.xmlreader.readsubtree%28v=vs.110%29.aspx). – dbc Nov 22 '15 at 18:26

0 Answers0