The XmlDocument class provides the ability to save XML data to files, streams and XmlWriters via the <b>Save</b> method. In this sample we are going to navigate over
the sample file <a target="_blank" href="/quickstart/util/srcctrlwin.aspx?path=/quickstart/howto/samples/Xml/SaveXmlDocument/&file=books.xml">books.xml</a>,
increase all the books prices by 2% and save the XML to a new file called
xmldocument.Load (new XmlTextReader (m_Document));
Console.WriteLine ("XmlDocument loaded with XML data successfully ...");
IncreasePrice(xmldocument.DocumentElement);
// Write out data as XML
xmldocument.Save(m_UpdatedDocument);
Console.WriteLine();
Console.WriteLine("Updated prices saved in file {0}", m_UpdatedDocument);
</xmp></div>
<div class="indent" style="width:660">
The IncreasePrice method recursively iterates over the XML document using the <b>FirstChild</b> method to move down the tree. This method returns null if
there are no child nodes. The <b>NextSibling</b> property moves to the node immediately next to the current node returning null if there is no node to move to.
Every time a node named 'price' is encountered, the price is updated. The code below illustrates this.