#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    Washington DC, USA
    Posts
    156
    Rep Power
    13

    XPath - getting the parent of a node where attribute = x


    Hello,


    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?


    -Cliff
  2. #2
  3. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    ..

    So the id of the parent element would be ../@id, and all of the treeitem nodes in the current tree would be ..//treeitem.

IMN logo majestic logo threadwatch logo seochat tools logo