Jump to content

XPath to get child node names


DominicWatson

Recommended Posts

Yes, and quite easily btw. Just use the name() funciton after the targeted node. For example:

/*/name()

will return the name of the root node of the XML, regardless of what that element is called.If you're using JavaScript, you can use the document.evaluate() object to cast a single XPath expression (as a string argument to this function) and get the node set as an object. There's only one problem, and if you have enough JavaScript knowledge already, you'll know it better then I do - IE. Yep, IE doesn't support the evaluate() object, and a few others btw.

Link to comment
Share on other sites

Yes, and quite easily btw. Just use the name() funciton after the targeted node. For example:
/*/name()

will return the name of the root node of the XML, regardless of what that element is called.

Hey, thanks for the reply. Unfortunately that produces an error for me (my XPath tool doesn't see it as a valid expression). Using Coldfusion with the following java class for using XPath: 'org.apache.xpath.CachedXPathAPI'Thanks again,Dominic
Link to comment
Share on other sites

Hey, thanks for the reply. Unfortunately that produces an error for me (my XPath tool doesn't see it as a valid expression). Using Coldfusion with the following java class for using XPath: 'org.apache.xpath.CachedXPathAPI'Thanks again,Dominic
Strange. It should have worked. Try local-name() instead.
Link to comment
Share on other sites

Hi there, I'm wondering if it's possible to build an XPath expression that will return just the names of the elements that it selects? At present my code to extract this data is exceedingly slow!Thanks in advance,Dominic
Hi Waston,In coldfusion, Xpath expression to get element name from source XML file.Use- Let Sample XML<catalog><book name="name1">..</book>..</catalog>"/catalog/name()"Try, and let me know your result.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...