开发者

Get the path of an element

is there a XPath function, which returns the absolute path of an element, so I can use it in sth. like:

<xsl:if test="path() = /root/parent/child">
   ...
</x开发者_如何学Pythonsl:if>

Thanks.


If you want to test if two nodes are the same, you must use generate-id():

<xsl:if test="generate-id(.) = generate-id(/root/parent/child)">
   <!-- The current node is the same as /root/parent/child -->
   ...
</xsl:if>

generate-id() returns an unique ID for each node of the document.


No, there isn't, but such expression '. = /root/parent/child' returns boolean and means the same.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜