Last active
August 29, 2015 14:01
-
-
Save jdowd7/a5771508d9f7698cfc68 to your computer and use it in GitHub Desktop.
change values within a xml node
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//parse the XML, might as well use Xpath to avoid dupe root nodes.... ughhhhh | |
System.Xml.XPath.XPathDocument xmlResults = new System.Xml.XPath.XPathDocument(customObjectThatHasXmlData.Data.InnerXml.ToString()); | |
System.Xml.XPath.XPathNavigator xmlResultsNav = xmlResults.CreateNavigator(); | |
System.Xml.XPath.XPathExpression xmlResultsExpression; | |
xmlResultsExpression = xmlResultsNav.Compile(@"/Data/result xmlns=""/time_stamp"); //in this case was trying to get the Tstamp | |
System.Xml.XPath.XPathNodeIterator xmlResultsNavIterator = xmlResultsNav.Select(xmlResultsExpression); | |
while(xmlResultsNavIterator.MoveNext()) | |
{ | |
if (xmlResultsNavIterator.Current.Name.Equals("time_stamp")) | |
{ | |
DateTime newDT = RoundUp(DateTime.Parse(xmlResultsNavIterator.Current.Value), TimeSpan.FromMinutes(5)); | |
xmlResultsNavIterator.Current.SetValue(newDT.ToString()); | |
} | |
} | |
//source: http://www.codeproject.com/Articles/9494/Manipulate-XML-data-with-XPath-and-XmlDocument-C |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
foreach (System.Xml.XmlNode node in mbsSearchResultData.Data)
{