2 Replies Latest reply on Jul 19, 2007 5:02 AM by jeroencornelissen

    E4X - @ value from queried subnode

    jeroencornelissen
      How to get an @ value from a node value, but the query is from the subnode...

      Maybe this is a strang formed question but let me explain via an example:

      part of the XML:

      <agr3 a13="05" a23="PBA" an3="2">
      <art3 aa13="05" aa23="845" acd3="" amc3="" abr3="000" aln3="000" apr3="000076,00"/>
      <art3 aa13="05" aa23="848" acd3="" amc3="" abr3="000" aln3="000" apr3="000080,00"/>
      <art3 aa13="05" aa23="861" acd3="" amc3="" abr3="000" aln3="000" apr3="000034,00"/>
      <art3 aa13="05" aa23="872" acd3="" amc3="" abr3="000" aln3="000" apr3="000084,00"/>
      </agr3>
      <agr3 a13="05" a23="PBD" an3="1">
      <art3 aa13="05" aa23="370" acd3="" amc3="" abr3="000" aln3="000" apr3="000030,00"/>
      </agr3>

      Query:

      rootxml..agr3. @an3.art3.( @aa13 == "05" && @aa23 == "370");


      So I need to retreive the an3 attribute, but it keeps returning "null".
      Is there a way to do this quickly with E4X?
        • 1. Re: E4X - @ value from queried subnode
          kleber.kiefer
          Hello,

          I don't know if I understood correctly, but try it:

          <?xml version="1.0" encoding="utf-8"?>

          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
          width="600" height="600" initialize="init();">

          <mx:Script>
          <![CDATA[

          import mx.controls.Alert;

          [Bindable]
          private var rootxml:XML =
          <agrs>
          <agr3 a13="05" a23="PBA" an3="2">
          <art3 aa13="05" aa23="845" acd3="" amc3="" abr3="000" aln3="000" apr3="000076,00"/>
          <art3 aa13="05" aa23="848" acd3="" amc3="" abr3="000" aln3="000" apr3="000080,00"/>
          <art3 aa13="05" aa23="861" acd3="" amc3="" abr3="000" aln3="000" apr3="000034,00"/>
          <art3 aa13="05" aa23="872" acd3="" amc3="" abr3="000" aln3="000" apr3="000084,00"/>
          </agr3>
          <agr3 a13="05" a23="PBD" an3="1">
          <art3 aa13="05" aa23="370" acd3="" amc3="" abr3="000" aln3="000" apr3="000030,00"/>
          </agr3>
          </agrs>;

          private function init():void {

          Alert.show(rootxml.agr3.art3.(@aa13=='05' && @aa23=='370').toXMLString(), 'Message');

          }

          ]]>
          </mx:Script>

          </mx:Application>
          • 2. Re: E4X - @ value from queried subnode
            jeroencornelissen Level 1
            No that wasn't what I was looking for, but it made me think :)
            I needed the parent of that subnode

            So the answer is : rootxml.agr3.art3.(@aa13=='05' && @aa23=='370').parent().@an3