2
votes

I have a XML in following format

<Body xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://schemas.xmlsoap.org/soap/envelope/">
  <TransactionAcknowledgement xmlns="">
    <TransactionId>HELLO </TransactionId>
    <UserId>MC</UserId>
    <SendingPartyType>SE</SendingPartyType>
  </TransactionAcknowledgement>
</Body>

I want to user XQuery or XPath expression for it.

Now I want to remove only

xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"

namespace from xml.

Is there any way to achieve it.

Thanks

1
XPath is a query language over XML document(a) and, as such, the evaluation of an XPath expression never modifies the source XML document(s) against which the expression is evaluated. What you need is an XML transformation. The best suited language for XML transformations is XSLT (XQuery can also be used, but is really clumsy because it lacks template matching). Would you be interested in an XSLT solution? - Dimitre Novatchev

1 Answers

0
votes

Try to use functx:change-element-ns-deep:

let $xml := <Body xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://schemas.xmlsoap.org/soap/envelope/">
  <TransactionAcknowledgement xmlns="">
    <TransactionId>HELLO </TransactionId>
    <UserId>MC</UserId>
    <SendingPartyType>SE</SendingPartyType>
  </TransactionAcknowledgement>
</Body>

return functx:change-element-ns-deep($xml, "http://schemas.xmlsoap.org/soap/envelope/", "")

But as said Dimitre Novatchev this function doesn't change namespace of the source xml, it creates a new XML.