Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You might want to check into something like Linq-to-XML:</p> <pre><code>XDocument coordinates = XDocument.Load("yourfilename.xml"); foreach(var coordinate in coordinates.Descendants("coordinate")) { string time = coordinate.Attribute("time").Value; string initial = coordinate.Element("initial").Value; string final = coordinate.Element("final").Value; // do whatever you want to do with those items of information now } </code></pre> <p>That should be a lot easier than using straight low-level XmlTextReader....</p> <p>See <a href="http://www.switchonthecode.com/tutorials/introduction-to-linq-simple-xml-parsing" rel="noreferrer">here</a> or <a href="http://colinmackay.co.uk/blog/2008/04/08/introduction-to-linq-to-xml/" rel="noreferrer">here</a> (or a great many other places) for introductions to Linq-to-XML.</p> <hr> <p><strong>UPDATE:</strong> </p> <p>please try this code - if it works, and you get all the coordinates in that resulting list, then the Linq-to-XML code is fine:</p> <p>Define a new helper class:</p> <pre><code>public class Coordinate { public string Time { get; set; } public string Initial { get; set; } public string Final { get; set; } } </code></pre> <p>and in your main code:</p> <pre><code>XDocument xdoc = XDocument.Load("C:\\test.xml"); IEnumerable&lt;XElement&gt; cords= xdoc.Descendants("coordinate"); var coordinates = cords .Select(x =&gt; new Coordinate() { Time = x.Attribute("time").Value, Initial = x.Attribute("initial").Value, Final = x.Attribute("final").Value }); </code></pre> <p>How does this list and its contents look like?? Do you get all the coordinates you're expecting??</p>
 

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