我无法转换xml文件 我有一个SOAP请求,我想将其转换为普通标签
e.g.<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-
ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://testnamespace.org">
<SOAP-ENV:Body>
<ns1:GetUserBalance>
<ns1:userId>tonysin</ns1:userId>
<ns1:currency>CNY</ns1:currency>
</ns1:GetUserBalance>
<ns1:loginToken>a1b2c3d4</ns1:loginToken>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
到
<GetUserBalance>
<userId>tonysin</userId>
<currency>CNY</currency>
</GetUserBalance>
<loginToken>a1b2c3d4</loginToken>
答案 0 :(得分:0)
我设法用这个xslt
完成了它<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://testnamespace.org">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="//SOAP-ENV:Body/node()"/>
</xsl:template>
<xsl:template match="*">
<xsl:element name="{local-name(.)}">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>