我有以下XML:複製輸入XML輸出並刪除不需要的命名空間出來的
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns="http:test/201/2"
xmlns:m0="http:test/201/3"
xmlns:ns0="http:test/201/4"
xmlns:ns2="http:test/201/5"
xmlns:ns1="http:test/201/6"
xmlns:ns3="http:test/201/7"
xmlns:ns6="http:test/201/8"
xmlns:ns4="http:test/201/9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Header>
<ns0:ResponseHeader>
<ns:Env>Dev</ns:Env>
<ns:Version>1</ns:Version>
<ns:Server></ns:Server>
<ns:Name>NAME</ns:Name>
</ns0:ResponseHeader>
</soap:Header>
<soap:Body>
<ns2:ResponseData>
<ns2:Employee >
<ns2:MessageList xsi:type="ns3:Info">
<ns2:Message>
<ns4:Type>new</ns4:Type>
<ns4:Code>2</ns4:Code>
<ns4:Source>Emp</ns4:Source>
<ns4:Description>new hire</ns4:Description>
</ns2:Message>
</ns2:MessageList>
<ns2:MessageList xsi:type="ns3:Info">
<ns2:Message>
<ns4:Type>new</ns4:Type>
<ns4:Code>1</ns4:Code>
<ns4:Source>contract</ns4:Source>
<ns4:Description>new hire</ns4:Description>
</ns2:Message>
</ns2:MessageList>
</ns2:Employee>
</ns2:ResponseData>
</soap:Body>
</soap:Envelope>
我的要求是,拷貝完整的輸入XML元素和屬性來輸出XML包括除的xmlns所有命名空間:SOAP =」 http://schemas.xmlsoap.org/soap/envelope/」。 所以慾望輸出是:
我的要求是,複製完整的輸入xml元素和屬性以輸出xml包括除xmlns之外的所有命名空間:soap =「http://schemas.xmlsoap.org/soap/envelope/」。 願意的話輸出是:
<Envelope
xmlns:ns="http:test/201/2"
xmlns:m0="http:test/201/3"
xmlns:ns0="http:test/201/4"
xmlns:ns2="http:test/201/5"
xmlns:ns1="http:test/201/6"
xmlns:ns3="http:test/201/7"
xmlns:ns6="http:test/201/8"
xmlns:ns4="http:test/201/9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Header>
<ns0:ResponseHeader>
<ns:Env>Dev</ns:Env>
<ns:Version>1</ns:Version>
<ns:Server></ns:Server>
<ns:Name>NAME</ns:Name>
</ns0:ResponseHeader>
</Header>
<Body>
<ns2:ResponseData>
<ns2:Employee >
<ns2:MessageList xsi:type="ns3:Info">
<ns2:Message>
<ns4:Type>new</ns4:Type>
<ns4:Code>2</ns4:Code>
<ns4:Source>Emp</ns4:Source>
<ns4:Description>new hire</ns4:Description>
</ns2:Message>
</ns2:MessageList>
<ns2:MessageList xsi:type="ns3:Info">
<ns2:Message>
<ns4:Type>new</ns4:Type>
<ns4:Code>1</ns4:Code>
<ns4:Source>contract</ns4:Source>
<ns4:Description>new hire</ns4:Description>
</ns2:Message>
</ns2:MessageList>
</ns2:Employee>
</ns2:ResponseData>
</Body>
</Envelope>
你的輸出包含'肥皂:Envelope'所以它需要有一些'的xmlns:SOAP = 「...」'聲明。 –
我的不好。肥皂前綴元素將被本地名稱替換。所以這就是爲什麼它不是必需的。所以最終的願望輸出是。 – Mike
請編輯您的問題的代碼示例以反映所需的輸出。看來你也已經用一個可接受的解決方案發布了一個類似的問題,這個問題不同嗎?如果是這樣,爲什麼? –