XML Files


Opening XML Files

Dim objXMLDocument As New System.XML.XMLDocument 
objXMLDocument.Load("C:\temp\myfile1.xml")


Saving XML Files

objXMLDocument.Save("C:\temp\myfile2.xml") 



Replacing Nodes




SelectNodes

This can select a list of nodes that match an XPath expression
If the XPath expression does not incude a prefix the namespace is assumed to be the empty namespace.
If your XML includes a namespace the this must be added to the XMLNamespaceManager and passed to the SelectNodes method



<xml_label xmlns="http://www.mywebsite.com"> 
   <tag1>
      <element>Value</element>
   </tag1>
</xml_label>

System.Xml.XMLNamespaceManager oManager; 
oManager = new System.Xml.XmlNamespaceManager(oXMLDocument.NameTitle);
oManager.AddNamespace("mv","http://www.mywebsite.com");
System.Xml.XMLNodeList oList = oXMLDocument.SelectNodes("//mw:tag1", oManager);



© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext