2 Replies Latest reply on Jul 18, 2007 5:07 AM by kleber.kiefer

    E4X - Search two agreed values

    kleber.kiefer
      Hello guys,

      I need your help!!! I have one xml (example):

      ===================================================================
      var xmlInterfaces:XML =
      <interfaces>
      <interface>
      <name>firstInterface</name>
      <team>TeamOne</team>
      <systems>
      <system>
      <name>SystemOne</name>
      </system>
      <system>
      <name>SystemTwo</name>
      </system>
      </systems>
      </interface>
      <interface>
      <name>secondInterface</name>
      <team>TeamTwo</team>
      <systems>
      <system>
      <name>SystemOne</name>
      </system>
      <system>
      <name>SystemTwo</name>
      </system>
      <system>
      <name>SystemThree</name>
      </system>
      </systems>
      </interface>
      </interfaces>;
      ===================================================================

      And I need to search for two agreed values (team=='TeamTwo' and systems.system.name=='SystemTwo'):

      ===================================================================
      xmlInterfaces.interface(team=='TeamTwo' && systems.system.name=='SystemTwo')
      ===================================================================

      But this don't work... it's return nothing...

      Please, you could help me?

      Thanks!!!
      Kleber

      PS.: Sorry my bad english!!!
        • 1. Re: E4X - Search two agreed values
          ntsiii Level 3
          Ok, this is strange.

          First, it appears that "interface] is a reserved word. I couldn't get anywhere until I changed it.

          then the closest I could do is get the "system" node. Of course, with that you could use parent() to get the desired parent node. Below is the sample app I used. There may be another way to do this.
          Tracy

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute"
          creationComplete="initApp()">

          <mx:Script><![CDATA[

          private function initApp():void
          {
          var xmlTemp:XML =
          <interfaces>
          <xinterface>
          <name>firstInterface</name>
          <team>TeamOne</team>
          <systems>
          <system>
          <name>SystemOne</name>
          </system>
          <system>
          <name>SystemTwo</name>
          </system>
          </systems>
          </xinterface>
          <xinterface>
          <name>secondInterface</name>
          <team>TeamTwo</team>
          <systems>
          <system>
          <name>SystemOne</name>
          </system>
          <system>
          <name>SystemTwo</name>
          </system>
          <system>
          <name>SystemThree</name>
          </system>
          </systems>
          </xinterface>
          </interfaces>;


          var xmlFind:XML = xmlTemp.xinterface.(team=='TeamTwo').systems.system.(name=='SystemTwo')[0];
          xmlFind = xmlFind.parent().parent();
          ta.text = xmlFind.toXMLString();
          }
          ]]></mx:Script>
          <mx:TextArea id="ta" width="400" height="600" />
          </mx:Application>

          • 2. Re: E4X - Search two agreed values
            kleber.kiefer Level 1
            Tracy,

            It's great!!! Thank's!!!

            But, one more question... and if existed one another node (example):

            var xmlTemp:XML =
            <interfaces>
            <xinterface>
            <name>firstInterface</name>
            <team>TeamOne</team>
            <systems>
            <system>
            <name>SystemOne</name>
            </system>
            <system>
            <name>SystemTwo</name>
            </system>
            </systems>
            <infoList>
            <info>
            <name>InfoOne</name>
            </info>
            <info>
            <name>InfoTwo</name>
            </info>
            </infoList>
            </xinterface>
            <xinterface>
            <name>secondInterface</name>
            <team>TeamTwo</team>
            <systems>
            <system>
            <name>SystemOne</name>
            </system>
            <system>
            <name>SystemTwo</name>
            </system>
            <system>
            <name>SystemThree</name>
            </system>
            </systems>
            <infoList>
            <info>
            <name>InfoOne</name>
            </info>
            <info>
            <name>InfoTwo</name>
            </info>
            <info>
            <name>InfoThree</name>
            </info>
            </infoList>
            </xinterface>
            </interfaces>;

            How to find (team=='TeamOne') AND systems.system.(name=='SystemTwo') AND infoList.info.(name=='InfoOne')????

            Thanks a lot!!!
            Kleber