Xml 搜索具有特定名称标记的节点
我正在尝试使用Xml 搜索具有特定名称标记的节点,xml,xslt,xpath,Xml,Xslt,Xpath,我正在尝试使用name=SomeName2对节点进行xslt,并将其子节点文本作为输出。我不知道它们在xml文件中的位置,在不同的xml文件中它们的位置总是不同的 是否有一个选项可以为节点名称而不是节点名称空间研究xml文件 这里是我的XML文件: <con1:node> <con2:node name="SomeName"> <con2:path>'Text'&l
name=SomeName2
对节点进行xslt,并将其子节点文本作为输出。我不知道它们在xml文件中的位置,在不同的xml文件中它们的位置总是不同的
是否有一个选项可以为节点名称而不是节点名称空间研究xml文件
这里是我的XML文件:
<con1:node>
<con2:node name="SomeName">
<con2:path>'Text'</con2:path>
</con2:node>
<con2:node name="SomeName2">
<con2:path>'Text'</con2:path>
</con2:node>
<con2:node name="SomeName3">
<con2:path>'Text'</con2:path>
</con2:node>
<con1:node>
“文本”
“文本”
“文本”
您可以使用:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:output indent="yes" method="text"/>
<xsl:template match="/">
<xsl:value-of select="//@name[normalize-space(.) = 'SomeName2']/parent::*"/>
</xsl:template>
</xsl:stylesheet>
这就是执行
/@name[规范化空格(.)='SomeName2']/parent::*
?为什么不/*[@name='SomeName2']
?