gpt4 book ai didi

xml - xsl 获取子节点

转载 作者:行者123 更新时间:2023-12-04 18:19:26 25 4
gpt4 key购买 nike

我是 xsl 的新手,需要帮助:(。我需要将子节点作为父注释的值。

<planet>
<venus> sometext
<mass>123</mass>
</venus>
<mars>text about mars</mars>
</planet>

所以我必须以这种形式得到它:
<venus>sometext
<mass>123</mass>
</venus>
<mars> text about mars <mars>

节点必须在符号“<”和“>”内,因为编译认为它们是父注释的内容。
谢谢!!!

最佳答案

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>

<xsl:template match="/">
<xsl:for-each select="*">
<xsl:apply-templates select="@*|node()"/>
</xsl:for-each>
</xsl:template>

<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

关于xml - xsl 获取子节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10995116/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com