Friday, April 3, 2015

Fish a particular value out serialized XML in C#.

int? versionNumber;
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.LoadXml(myBlobOfXml);
foreach (XmlNode outerXmlNode in xmlDocument)
{
   foreach (XmlNode innerXmlNode in outerXmlNode)
   {
      if (innerXmlNode.Name == "Version")
      {
         versionNumber = Convert.ToInt32(innerXmlNode.InnerText);
      }
   }
}

No comments:

Post a Comment