Secondary menu

Main menu

Q & A - Selecting the Current Node's Children in XPath

Q: I am enjoying your book but wanted to address something in your chapter on XPath Patterns and Expressions that needs clarification. On page 42, on your second tip, you say that by typing * (an asterisk) you select all the current node's children, but don’t you mean that 'element_name/*' will select all the current node’s children?

A: I’m very glad to hear that you’re enjoying the book. In answer to your question, in XPath you actually do not need to specify an ‘element_name/’ before using * (an asterisk) to select all the current node’s children. For me, the key is knowing what XPath considers as the current node. Following are links to examples based on the Figure i-01 in the book; it includes an xml file, xsl file, and the resulting HTML file. (To view the files, please right-click and save to your local machine.) Hopefully, this helps clarify what you are asking.


Back to the Q & A page

© 2009 - 2021 Kevin Howard Goldberg