2 Replies Latest reply on Feb 9, 2007 3:03 PM by AMTuring

    e4x search in nested XML

    Scott Stroz Level 1
      I have some XML I am using to populate a Tree control. This tree is being used as part of a form to assign topics to a specific item. When I go to edit the item, I need to pre-select the appropriate item from the tree. I have been trying to use e4x syntax to search for the necessary items, but unless the topic is one of the top level topics, I am unable to get anything returned from the e4x.

      Here is my XML:

      <?xml version="1.0" encoding="UTF-8"?>
      <topic data="23" label="News" parent="0">
      <topic data="24" label="National" parent="23">
      <topic data="28" label="Politics" parent="24"/>
      <topic data="25" label="Local" parent="23">
      <topic data="29" label="Community" parent="25"/>
      <topic data="27" label="Politics" parent="25"/>
      <topic data="26" label="International" parent="23"/>
      <topic data="30" label="Sports" parent="0">
      <topic data="31" label="Football" parent="30">
      <topic data="33" label="College" parent="31"/>
      <topic data="34" label="NFL" parent="31"/>
      <topic data="32" label="Baseball" parent="30">
      <topic data="35" label="Major Leagues" parent="32"/>
      <topic data="36" label="Minor Leagues" parent="32"/>
      <topic data="37" label="Classifieds" parent="0"/>

      I have a variable, of type XML, named treeData that holds the XML and is used as the dataprovider for the tree.

      When I use this:


      It should alert with 'Major Leagues', but instead, no text appears.

      When I use this:


      I get an alert with 'Classifieds' in it.

      Does an e4x search not recurse through all nodes and child nodes? Can someone help me figure this out?

      Thanx in advance.
        • 1. Re: e4x search in nested XML
          inlineblue Level 1
          There's a separate syntax for recursive searches (two dots):

          • 2. Re: e4x search in nested XML
            Hi Scott,

            I have a similar problem.

            The trouble is not on the recursion, the interpreter does recurse. The trouble is when there a multiple children for the same tag name.

            Try the same example but with some <topics> parent having ONLY ONE <topic> child and this child having the @id you like. Then the query find it withou problem (and all the <topic> childrens without siblings fullfiling the query condition).

            That the problem, BUT I have no solution to this, and I would appreciate any idea to solve, or any alternative for performing such a usual query.