XSL 转换 - 删除父节点

发布于 2024-08-09 02:15:35 字数 920 浏览 4 评论 0原文

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:enterprise.soap.sforce.com">
 <soapenv:Body>
  <upsertResponse>
   <result>
    <created>true</created>
    <id>0011</id>
    <success>true</success>
   </result>
   <result>
    <created>false</created>
    <id>0012</id>
    <success>true</success>
   </result>
  </upsertResponse>
 </soapenv:Body>
</soapenv:Envelope>

**How can I transform this to** 

<upsertResponse>
 <result>
  <created>true</created>
  <id>0011</id>
  <success>true</success>
 </result>
 <result>
  <created>false</created>
  <id>0012</id>
  <success>true</success>
 </result>
</upsertResponse>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:enterprise.soap.sforce.com">
 <soapenv:Body>
  <upsertResponse>
   <result>
    <created>true</created>
    <id>0011</id>
    <success>true</success>
   </result>
   <result>
    <created>false</created>
    <id>0012</id>
    <success>true</success>
   </result>
  </upsertResponse>
 </soapenv:Body>
</soapenv:Envelope>

**How can I transform this to** 

<upsertResponse>
 <result>
  <created>true</created>
  <id>0011</id>
  <success>true</success>
 </result>
 <result>
  <created>false</created>
  <id>0012</id>
  <success>true</success>
 </result>
</upsertResponse>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

青衫儰鉨ミ守葔 2024-08-16 02:15:36

使用选择元素,然后放置一个;在它里面。那应该可以解决问题。抱歉,我没有确切的语法,但希望这能为您指明正确的方向。

Use an <xsl:match> to select the <upsertResponse> element, then put an <xsl:copy> inside of it. That should do the trick. Sorry I don't have the exact syntax, but hopefully this points you in the right direction.

女中豪杰 2024-08-16 02:15:35

这是一个 XSL 示例,它采用根的第一个子节点的第一个子节点并将其作为新 XML 的根节点:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

     <xsl:template match="/">
          <xsl:copy-of select="./*[1]/*[1]/*[1]" />
     </xsl:template>

</xsl:stylesheet>

请注意,您只能采用一个节点而不能采用多个节点,因为将很少的节点作为 XML 的根节点无效。

This is an example of XSL that takes the first child of first child of root and makes it root node of new XML:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

     <xsl:template match="/">
          <xsl:copy-of select="./*[1]/*[1]/*[1]" />
     </xsl:template>

</xsl:stylesheet>

Please note that you can take only one node and not multiple nodes since placing few nodes as root of XML is not valid.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文