Occur error "Object reference not set to an instance of an object" in executing XmlNode operation

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi Guys,

I writed a class to modify xml document. Following code is this class.

<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; class ModifyXMLFile
{
<span style="color:Blue; public XmlDocument modifyxmlfile(XmlDocument xmlDoc, <span style="color:Blue; string xpathString, <span style="color:Blue; string modifyString)
{
XmlNode node = xmlDoc.SelectSingleNode(xpathString);
node.InnerText = modifyString;
<span style="color:Blue; return xmlDoc;
}
}
[/code]

The "xpathString" is xpath expression.
<br/>
When the xml file is small and simple, the class can work successfully.
However, when the xml file is very large, in fact, the xml file is a xmla file like xml and 10MB, the pragram will occur error in line "node.InnerText = modifyString". The description of error is "Object reference not set to an instance of an object".
How can I solute this error?
Thanks.

Regards,
Kaneabell

View the full article
 
Back
Top