Monday, September 8, 2014

An example of using XDocument in C# to read and make sense of XML.

In this example myMagicString would just hold XML:

XDocument xDocument = XDocument.Parse(myMagicString);
foreach (XElement child in xDocument.Root.Elements())
{
   if (child.Name == "statuscode")
   {
      DoWhatever(child.Value);
   }
}

 
 

You would use .Load instead of .Parse methinks if myMagicString held the name of a file to crawl.

No comments:

Post a Comment