How do I remap all namespace prefix references to other values?
In a C# application I am using XmlDocument with SelectNodes Xpath Queries
and the XmlNamespaceManager like this:
xmlDoc.SelectSingleNode("/ns2:myElement2", nsmgr);
This works great but a customer has started passing us XML with different namespace prefixes. It still validates the schema but the XPath queries never
return a result obviously due to the namespace prefix change.
Say this is my source document:
<myRoot xmlns:ns1="someURI" xmlns:ns2="someURI2" xmlns:ns2="someURI3">
<ns1:myElement1 />
<ns2:myElement2 />
<ns3:myElement3 />
</myRoot>
How can I translate it to this?
<myRoot xmlns:aa="someURI" xmlns:bb="someURI2" xmlns:cc="someURI3">
<aa:myElement1 />
<bb:myElement2 />
<cc:myElement3 />
</myRoot>
Do I need to do some kind of XSLT transformation?
Any clues would be appreciated.
Thanks!
In a C# application I am using XmlDocument with SelectNodes Xpath Queries
and the XmlNamespaceManager like this:
xmlDoc.SelectSingleNode("/ns2:myElement2", nsmgr);
This works great but a customer has started passing us XML with different namespace prefixes. It still validates the schema but the XPath queries never
return a result obviously due to the namespace prefix change.
Say this is my source document:
<myRoot xmlns:ns1="someURI" xmlns:ns2="someURI2" xmlns:ns2="someURI3">
<ns1:myElement1 />
<ns2:myElement2 />
<ns3:myElement3 />
</myRoot>
How can I translate it to this?
<myRoot xmlns:aa="someURI" xmlns:bb="someURI2" xmlns:cc="someURI3">
<aa:myElement1 />
<bb:myElement2 />
<cc:myElement3 />
</myRoot>
Do I need to do some kind of XSLT transformation?
Any clues would be appreciated.
Thanks!