Re: Apparent documentation contradiction for XmlNode.SelectSingleNode(





SailBoffin wrote:

I just noticed something confusing the MSDN documentation for the XmlNode.SelectSingleNode() function here

http://msdn2.microsoft.com/en-us/library/fb63z0tw.aspx

It says, under the "Return Value" section that "The XmlNode should not be expected to be connected "live" to the XML document." but in the sample code modifies the node returned from the function and then prints the entire document. Did I mis-interpret the description of the return value or is the sample wrong? I've done this before and it's always worked AFAIK.

I am not sure why that comment is in there, as SelectSingleNode is a method exposed on the .NET DOM implementation with XmlNode, XmlDocument where you are supposed to be able to edit/manipulate nodes it does not make much sense to say the node returned by SelectSingleNode is not "connected live" and "changes that appear in the XML document may not appear in the XmlNode, and vice versa". In particular as there is no clear explanation given on how you could then use the SelectSingleNode result to get a node that is connected live to ensure changes you make are committed.


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
.



Relevant Pages

  • Re: XmlNode.SelectSingleNode() Question
    ... The first XmlNode that matches the XPath query or a null reference if no matching node is found. ... That is, changes that appear in the XML document may not appear in the XmlNode, and vice versa. ... If I am reading it correctly, it means that if you load an xml file into the XML DOM, then make changes to the file, then query the XML DOM via SelectSingleNode, don't expect the changes to the file to show up in your results. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Receiving XML Documents
    ... properly serialized as an XML element. ... By a string type element ... but because the XML document is wrapped into a string ... Create a webservice that accepts a XMLNode. ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: Receiving XML Documents
    ... properly serialized as an XML element. ... By a string type element ... but because the XML document is wrapped into a string ... Create a webservice that accepts a XMLNode. ...
    (microsoft.public.dotnet.xml)
  • Re: Adding attributes to an element
    ... XmlDocument xmlDoc = new XmlDocument; ... XmlNode xmlNode; ... > I have an XML document and I need to add some attributes to an element. ...
    (microsoft.public.dotnet.xml)
  • XPath with ADO XML
    ... I've checked Google and the ... I have an XML document that I pass to another function with an XPath ... The function then uses that XPath query with SelectSingleNode ...
    (microsoft.public.dotnet.languages.vb)

Loading