Thanks all. Must have been my void of XPath knowledge at play here.
I was trying to write something like
SelectSingleNode("//ns1:OrderId")
without having to register "ns1" in the namespace manager object.
I have since resolved to use
string xPathPrefix = xmlDocument.DocumentElement.Prefix;
string xNameSpace = xmlDocument.DocumentElement.Attributes["xmlns:" +
xPathPrefix].Value;
And plowing forward into the NamespaceManager usage from there.
Allows me to not need to know the specifics of namespaces, atleast so
far.
Martin Honnen wrote:
br***********@gmail.com wrote:
I need to be able to read some element values and populate some
element values for some XML documents submitted to a service, but I can
not predict the NameSpace in the documents.
I have been using the System.Xml.XmlDocument object with success for
a known NameSpace and using the NameSpaceManager object with it. Is
there a way to Load some XML into the DOM and manipulate it without
having to know the Namespace?
I need to read and write into the elements.
If you know the element names but not the namespace then you could use
XPath expressions alike e.g.
//*[local-name() = 'the-element-name-here']
to find elements.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/