On Apr 12, 11:35 am, Martin Honnen <mahotr...@yahoo.dewrote:
chance wrote:
okay suppose the XML is in a file called C:\\XMLFile1.xml
Then instead of LoadXml use the Load method
XmlDocument doc = new XmlDocument();
doc.Load(@"C:\XMLFile1.xml");
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Okay I'm getting this run-time error and I don't know why...
This is my function:
private string getParams(XmlDocument xmlDoc, string key)
{
string retVal;
retVal = xmlDoc.SelectSingleNode("/parameters/parm[col='" +
key + "']/val").InnerText;
return retVal;
}
This is the call:
//read XML and append
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("C:\\XMLFile1.xml");
string test = getParams(xmlDoc,
"notice_of_violation.notice_of_violation_id");
And this is the contents of the XML file:
<?xml version="1.0" encoding="utf-8" ?>
- <parameters>
- <parm>
<col>notice_of_violation.notice_of_violation_id</col>
<val>A1000125</val>
</parm>
</parameters>
This is the error:
System.NullReferenceException: Object reference not set to an instance
of an object.
at reportNOV.getParams(XmlDocument xmlDoc, String key) in c:
\Documents and Settings\dchance\My Documents\Visual Studio
2005\WebSites\DocServerII\App_Code\rptNOV.cs:line 33
at reportNOV.generateNOV(String xmlParms) in c:\Documents and
Settings\dchance\My Documents\Visual Studio 2005\WebSites\DocServerII
\App_Code\rptNOV.cs:line 65
at Service.buildDocument(String rptType, String accessKey, String
xmlParms) in c:\Documents and Settings\dchance\My Documents\Visual
Studio 2005\WebSites\DocServerII\App_Code\Service.cs:line 40