1 Reply Latest reply on May 11, 2006 3:30 PM by rwest

    Parent node of an XML Search

      I have been wrecking my brain on this and I am sure that it is possible I am just not sure what the proper search expression is.

      If I have an XML document like this:

      Lets say I am looking for the parent of the item element that has a linkurl element with value of "bar" I would expect to write something like this:

      <cfset itemArray = xmlSearch(xmlDoc, "ancestor:://item[linkurl='bar']")>

      I know that for this particular instance I could access it directly but in my case there may be many <item> tags nested so I want it to be dynamic so that I can continue to walk back up the tree.

      Any help will be appreciated
        • 1. Re: Parent node of an XML Search
          rwest Level 1
          This was posted a couple of times because of a bad internet connection, anyways with my trusty XPath Explorer plugin I was able to get the solution:

          <cfset itemArray = xmlSearch(xmlDoc, "//item[linkurl='bar']/parent::item")>

          If you have started to play with XML and XPath in particular and you are using Eclipse the XPath Explorer plugin is invaluable!