1 Reply Latest reply on Nov 13, 2006 4:56 AM by Newsgroup_User

    Tree: How can I find a node from attribute value?

    jgeorgiou
      Hi all ,
      I have a large xml (about 3,000 nodes). You can see the format to the attached code bellow.
      I use the tree component as the contents of a book, so I have chapters, subchapters etc.
      My answer is how can I find (search) using xPath or other way, a node from the attribute's value?
      i.e. I search using the string "2.3" and I want to get the node CHAPTER 2 / SUBCHAPTER 3

      Thanks in advance for any available help.
      I would appreciate any example found to this community.
        • 1. Re: How can I find a node from attribute value?
          Level 7
          Assuming the data nodes are children of the root node:

          trace(XPathAPI.selectSingleNode(myxmldata.firstChild,
          "*/node/node[@value='2.4']"))


          <root>
          <node label="chapter 1" value="1">
          <node label="subchapter 1" value="1.1"/>
          <node label="subchapter 2" value="1.2"/>
          <node label="subchapter 3" value="1.3"/>
          <node label="subchapter 4" value="1.4"/>
          </node>
          <node label="chapter 2" value="2">
          <node label="subchapter 1" value="2.1"/>
          <node label="subchapter 2" value="2.2"/>
          <node label="subchapter 3" value="2.3"/>
          <node label="subchapter 4" value="2.4"/>
          </node>
          </root>