2

我有以下格式的 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>

我想为它使用 XQuery 或 XPath 表达式。

现在我只想删除

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

来自 xml 的命名空间。

有没有办法实现它。

谢谢

4

1 回答 1

0

尝试使用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/", "")

但正如 Dimitre Novatchev 所说,这个函数不会改变源 xml 的命名空间,它会创建一个新的 XML。

于 2012-09-02T18:08:06.553 回答