Here is how it will work :
XmlDocument xmlDoc = new XmlDocument()xmlDoc.Load(@"C:\Well.xml")XmlNode node = xmlDoc.SelectSingleNode("/gpx/waypoints/waypoint[@a='2']/name")node.InnerText = "Something"xmlDoc.Save(@"C:\Well.xml")
Hope it helped!
From the subject of your question, it seems that you don't want to load the whole XML.
Well there is a class
which is a stream-based loading of XML and it won't load the whole XML. It will read node by node, in contrast to
which is a in-memory based loading of XML, it loads the whole XML into memory.
Now coming back to the point, after searching for more info on the internet, it was just like I thought,
cannot modify the Xml nodes. So your solution will be to use the
itself for Modifying the nodes.
I did however tried in this way :
XmlTextReader reader = new XmlTextReader(path);
if (reader.NodeType == XmlNodeType.Element && reader.Name == "waypoint")
if (reader.GetAttribute("a") == "2")
XmlDocument xmlDoc = new XmlDocument();
XmlNode node = xmlDoc.SelectSingleNode(".");
node.InnerText = "Something";
So it didn't work for me.
I will still try to figure out a solution for this.
Found some articles in CodeProject. According your requirements, check these :
-First you can split your large xml file into smaller ones. Check this article : http://www.codeproject.com/KB/XML/SplitLargeXMLintoSmallFil.aspx#xx2994884xx
- After finding the node, load the smaller XML into an XmlDocument and then edit like I did in my solution. Then merge the xml files like mentioned in this article : http://www.codeproject.com/KB/XML/XStreamingElement_Merge.aspx
Try it out. Good luck!