S
Steve Harclerode
I saw something in the Microsoft documentation for SelectNodes() that I've
never noticed before today:
-----
Return Value
The first XmlNode that matches the XPath query or a null reference (Nothing
in Visual Basic) if no matching node is found. The XmlNode should not be
expected to be connected "live" to the XML document. That is, changes that
appear in the XML document may not appear in the XmlNode, and vice versa.
-----
If I'm reading this correctly, this means that you can't expect code like
this to work:
XmlElement myval = xmlDocument.SelectSingleNode(@"//SomeElement") as
XmlElement;
if (myval != null) {
myval.InnerText = "my content";
}
I see examples like the above all over the place...
Am I reading the documentation correctly? If so, what's the "correct" way to
update nodes in an XmlDocument?
Thanks,
Steve
never noticed before today:
-----
Return Value
The first XmlNode that matches the XPath query or a null reference (Nothing
in Visual Basic) if no matching node is found. The XmlNode should not be
expected to be connected "live" to the XML document. That is, changes that
appear in the XML document may not appear in the XmlNode, and vice versa.
-----
If I'm reading this correctly, this means that you can't expect code like
this to work:
XmlElement myval = xmlDocument.SelectSingleNode(@"//SomeElement") as
XmlElement;
if (myval != null) {
myval.InnerText = "my content";
}
I see examples like the above all over the place...
Am I reading the documentation correctly? If so, what's the "correct" way to
update nodes in an XmlDocument?
Thanks,
Steve