Name of current element from XmlPath

21 views
Skip to first unread message

Robin Green

unread,
Nov 22, 2011, 1:11:46 PM11/22/11
to scales-xml
XPath has the name() function to get the name of the current node. How
do I get the name of the focused element from an XmlPath? (I just want
to put in a require to sanity-check I've got the right element.)
This message has been checked for all known viruses by the Postini Virus Control Centre.

Chris

unread,
Nov 22, 2011, 2:22:07 PM11/22/11
to scales-xml
Hi Robin,

You can use Elements.Functions.qname(currentFocus) to get the name()
equivalent.

For use in require I'd check against the namespace as well (prefixes
can lie :<). Elements.Functions.qualifiedName or
elem(focus).name.qualifiedName will return the following syntax in
XPath function terms:

{namespace-uri()}local-name()

If you want to test on prefix as well then pqName will also add
prefix: to the front of the above string.

All of these functions are also available within the internal XPath
syntax e.g. root.\*(qualifiedName(_) == "{ns}local")

HTH,
Chris

Reply all
Reply to author
Forward
0 new messages