In. NET, it was a bit odd to read the prompts in the program that read the XML to "not set an object reference to an instance of an object." Why you should instantiate an object while reading the XML data. Google did not know that the XML file included the xmlns representation namespace, But XPath must also be added.
As previously our XML file is defined as:
<project name= "Target planning Project" >
<process name= "Personal monthly Plan" description= "personal monthly Plan" version= "1" >
<node name= "Start" type= "Start" description= "Begin" >
<Event></Event>
</Node>
</Process>
</Project>
We read just
XmlDocument xmldoc = new XmlDocument ();
Xmldoc.load (path);
String xPath = @ "Project/process";
XmlNode xn = xmldoc.selectsinglenode (XPath);
This writing
If XML is defined like this
<project xmlns= "http://tempuri.org/XMLSchema.xsd" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi: Schemalocation= "Http://tempuri.org/XMLSchema.xsd
Wfpd.xsd "name=" target program >
<process name= "Personal monthly Plan" description= "personal monthly Plan" version= "1" >
<node name= "Start" type= "Start" description= "Begin" >
<Event></Event>
</Node>
</Process>
</Project>
We must call this when we read it.
XmlDocument xmldoc = new XmlDocument ();
Xmldoc.load (path);
XmlNamespaceManager xnm = new XmlNamespaceManager (xmldoc.nametable);
Xnm. AddNamespace ("Mxh", "http://tempuri.org/XMLSchema.xsd");
String xPath = @ "/mxh:project/mxh:process";
XmlNode xn = xmldoc.selectsinglenode (XPath, xnm);
Ok! 's got a lot of insight.