我从 SharePoint 应用程序收到这样的响应
Input
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<SharepointResponse xmlns="http://test.com.services.generic">
<Sharepoint_Response><?xml version="1.0" encoding="UTF-8"?>
<CopyIntoItemsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<CopyIntoItemsResult>0</CopyIntoItemsResult>
<Results>
<CopyResult ErrorCode="Success" DestinationUrl="http://archivelink.dev.test.com/"/>
</Results>
</CopyIntoItemsResponse></Sharepoint_Response>
</SharepointResponse>
</Body>
</Envelope>
我正在使用这个代码
Code :
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes" encoding="utf-8"/>
<!--Identity template simply copies content forward -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates select="*" />
<xsl:value-of select="text()" disable-output-escaping="yes"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
给出输出:
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<SharepointResponse xmlns="http://test.com.services.generic">
<Sharepoint_Response><?xml version="1.0" encoding="UTF-8"?>
<CopyIntoItemsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<CopyIntoItemsResult>0</CopyIntoItemsResult>
<Results>
<CopyResult ErrorCode="Success" DestinationUrl="http://archivelink.dev.test.com/enterprise/"/>
</Results>
</CopyIntoItemsResponse></Sharepoint_Response>
</SharepointResponse>
</Body>
</Envelope>
我不知道如何删除这个<?xml version="1.0" encoding="UTF-8"?>
after <Sharepoint_Response>
预期输出:
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<SharepointResponse xmlns="http://test.com.services.generic">
<Sharepoint_Response>
<CopyIntoItemsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<CopyIntoItemsResult>0</CopyIntoItemsResult>
<Results>
<CopyResult ErrorCode="Success" DestinationUrl="http://archivelink.dev.test.com/enterprise/"/>
</Results>
</CopyIntoItemsResponse></Sharepoint_Response>
</SharepointResponse>
</Body>
</Envelope>
你可以尝试这样的事情:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes" encoding="utf-8" />
<!--Identity template simply copies content forward -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates select="*" />
<xsl:value-of select="substring-after(text(),'?>')" disable-output-escaping="yes" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
这个想法是使用substring-after
关闭后获得一切?>
XML 声明的一部分。使用该样式表给了我以下输出:
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<SharepointResponse xmlns="http://test.com.services.generic">
<Sharepoint_Response>
<CopyIntoItemsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<CopyIntoItemsResult>0</CopyIntoItemsResult>
<Results>
<CopyResult ErrorCode="Success" DestinationUrl="http://archivelink.dev.test.com/"/>
</Results>
</CopyIntoItemsResponse></Sharepoint_Response></SharepointResponse></Body></Envelope>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)