Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is the best way to parse (big) XML in C# Code?
    text
    copied!<p>I'm writing a GIS client tool in C# to retrieve "features" in a GML-based XML schema (sample below) from a server. Extracts are limited to 100,000 features.</p> <p>I guestimate that the largest <em>extract.xml</em> might get up around 150 megabytes, so obviously DOM parsers are out I've been trying to decide between <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx" rel="noreferrer" title="XmlSerializer">XmlSerializer</a> and <a href="http://msdn.microsoft.com/en-us/library/x6c1kb0s.aspx" rel="noreferrer" title="XSD.EXE - Visual Studio XML-schema-binder generator tool">XSD.EXE</a> generated bindings --OR-- <a href="http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx" rel="noreferrer" title="XmlReader class">XmlReader</a> and a hand-crafted object graph.</p> <p>Or maybe there's a better way which I haven't considered yet? Like XLINQ, or ????</p> <p>Please can anybody guide me? Especially with regards to the memory efficiency of any given approach. If not I'll have to "prototype" both solutions and profile them side-by-side. </p> <p>I'm a bit of a raw prawn in .NET. Any guidance would be greatly appreciated. </p> <p>Thanking you. Keith.</p> <hr> <p><strong>Sample XML</strong> - upto 100,000 of them, of upto 234,600 coords per feature.</p> <pre><code>&lt;feature featId="27168306" fType="vegetation" fTypeId="1129" fClass="vegetation" gType="Polygon" ID="0" cLockNr="51598" metadataId="51599" mdFileId="NRM/TIS/VEGETATION/9543_22_v3" dataScale="25000"&gt; &lt;MultiGeometry&gt; &lt;geometryMember&gt; &lt;Polygon&gt; &lt;outerBoundaryIs&gt; &lt;LinearRing&gt; &lt;coordinates&gt;153.505004,-27.42196 153.505044,-27.422015 153.503992 .... 172 coordinates omitted to save space ... 153.505004,-27.42196&lt;/coordinates&gt; &lt;/LinearRing&gt; &lt;/outerBoundaryIs&gt; &lt;/Polygon&gt; &lt;/geometryMember&gt; &lt;/MultiGeometry&gt; &lt;/feature&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload