Hello,

I was just curious if anyone had an idea as to why trace examples 
examples 3,4,and 5 for myXML1 and myXML3 in the code snippet from the
last post don't return what you'd expect from viewing the xml whereas
3,4,5 for myXML2 does.  I think it's a bug in AS3 with e4x expressions
and xml nodes without children, but I figured I'd see if anyone in the
group would be able to prove otherwise.

Main reason this is a concern is because I am trying to programatically
select a node in a tree that's driven by an XML file using this
functionality of e4x.

Thanks in advance,
Jun

--- In [email protected], "coderjun" <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> I have been working on a tree control that's driven by an xml file.
> What I have be trying to do is to select an item in the tree by first
> searching the dataProvider, the XML object that represents the xml
file.
>
> What I have noticed is that the expressions >, <, and == don't seem to
> work on attributes in nodes that do not have any children. Remember,
> this is an xml file for a tree control and I may have items that don't
> have any children.
>
> This to me seems very odd, especially since >= and <= seem to work
just
> fine...
>
> I submitted a bug report on the Adobe site but since they won't
respond
> to a bug submittal I figured I'd post it here to see if anyone had a
> response or experience with my issue.  It's really frustrating since
> this issue is preventing me from accessing a single node in the xml
> directly.
>
> Below is a code example, as simple as possible, I took the file and
the
> tree control out of the equation.  (I also based my XML for the
example
> off of sample code from the Flex help docs.)
>
> You'll notice what is broken that you'd think would work is trace
> examples 3,4,and 5 for myXML1 and myXML3.
>
> -Jun
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
>      layout="absolute"
>      creationComplete="onCreationComplete()">
>      <mx:Script>
>          <![CDATA[
>              private var myXML1:XML=<order>
>                  <book ISBN="1">
>                      <title>Baking Extravagant Pastries with
> Kumquats</title>
>                      <author>
>                          <lastName>Contino</lastName>
>                          <firstName>Chuck</firstName>
>                      </author>
>                      <pageCount>238</pageCount>
>                  </book>
>                  <book ISBN="2" />
>                  <book ISBN="3">
>                      <title>Emu Care and Breeding</title>
>                      <editor>
>                          <lastName>Case</lastName>
>                          <firstName>Justin</firstName>
>                      </editor>
>                      <pageCount>115</pageCount>
>                  </book>
>              </order>;
>
>              private var myXML2:XML=<order>
>                  <book ISBN="1">
>                      <title>Baking Extravagant Pastries with
> Kumquats</title>
>                      <author>
>                          <lastName>Contino</lastName>
>                          <firstName>Chuck</firstName>
>                      </author>
>                      <pageCount>238</pageCount>
>                  </book>
>                  <book ISBN="3" />
>                  <book ISBN="2">
>                      <title>Emu Care and Breeding</title>
>                      <editor>
>                          <lastName>Case</lastName>
>                          <firstName>Justin</firstName>
>                      </editor>
>                      <pageCount>115</pageCount>
>                  </book>
>              </order>;
>
>              private var myXML3:XML=<order>
>                  <book ISBN="1" ></book>
>                  <book ISBN="2" ></book>
>                  <book ISBN="3" ></book>
>              </order>;
>
>              private function onCreationComplete():void
>              {
>                  // Trace out pieces of myXML1
>                  trace('~~~~ myXML1 START ~~~~');
>                  trace('myXML1 EXAMPLE 1: ' + myXML1.book[0]);
>                  trace('myXML1 EXAMPLE 2: ' + myXML1.book.(@ISBN >= 1
&&
> @ISBN <= 3));
>                  trace('myXML1 EXAMPLE 3: ' + myXML1.book.(@ISBN > 1
&&
> @ISBN < 3));
>                  trace('myXML1 EXAMPLE 4: ' + myXML1.book.(@ISBN==2));
>                  trace('myXML1 EXAMPLE 5: ' +
> myXML1..*.(attribute('ISBN')==2));
>                  trace('~~~~~~~~~~~~~~~~~~~~~~');
>
>                  // Trace out pieces of myXML2
>                  trace('~~~~ myXML2 START ~~~~');
>                  trace('myXML2 EXAMPLE 1: ' + myXML2.book[0]);
>                  trace('myXML2 EXAMPLE 2: ' + myXML2.book.(@ISBN >= 1
&&
> @ISBN <= 3));
>                  trace('myXML2 EXAMPLE 3: ' + myXML2.book.(@ISBN > 1
&&
> @ISBN < 3));
>                  trace('myXML2 EXAMPLE 4: ' + myXML2.book.(@ISBN==2));
>                  trace('myXML2 EXAMPLE 5: ' +
> myXML2..*.(attribute('ISBN')==2));
>                  trace('~~~~~~~~~~~~~~~~~~~~~~');
>
>                  // Trace out pieces of myXML3
>                  trace('~~~~ myXML3 START ~~~~');
>                  trace('myXML3 EXAMPLE 1: ' + myXML3.book[0]);
>                  trace('myXML3 EXAMPLE 2: ' + myXML3.book.(@ISBN >= 1
&&
> @ISBN <= 3));
>                  trace('myXML3 EXAMPLE 3: ' + myXML3.book.(@ISBN > 1
&&
> @ISBN < 3));
>                  trace('myXML3 EXAMPLE 4: ' + myXML3.book.(@ISBN==2));
>                  trace('myXML3 EXAMPLE 5: ' +
> myXML3..*.(attribute('ISBN')==2));
>                  trace('~~~~~~~~~~~~~~~~~~~~~~');
>              }
>          ]]>
>      </mx:Script>
> </mx:Application>
>


Reply via email to