October 7th, 2002, 12:34 AM
XPath - getting the parent of a node where attribute = x
I have an XML document that consists of the same element type (called treeitem) embedded in itself representing a very genericized tree structure.
That I'd like to do is use XPATH to search the entire document for a treeitem element with attribute id=int, where int is any number. I wrote the XPATH to grab the treeitem itself:
//treeitem[@id=x] where x is an integer passed dynamically
but now I can't see to get XPATH to give me the parent of that guy that I just grabbed. How can I accomplish this?
October 7th, 2002, 11:38 AM
So the id of the parent element would be ../@id, and all of the treeitem nodes in the current tree would be ..//treeitem.