When displaying XML, always use toXMLString().  The behavior you are
seeing with toString() which is what trace uses, is actually comformant
with ECMA.

 

trace(myXML.toXMLString());

 

Tracy

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Derrick Anderson
Sent: Tuesday, April 15, 2008 3:20 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] pulling my hair out with e4x!!!

 

yes, i tried it and have it working now- mostly user error but I must
say not being able to debug e4x expressions has ruined my day on many
occasions.

i was using toString on the xml list, thinking it would show me the xml
node it found and children (if any), toString was returning nothing and
a length of 0 so I assumed nothing was coming back.  when i added
children, the toString started showing me the node i was trying to find.

so, the blank response held the object i was looking for- but toString
was not showing it.

thanks for your help on this!
d.

On Tue, Apr 15, 2008 at 2:53 PM, Daniel Gold <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote:

I've never used the attribute syntax you're using, so I'm not familiar
with it, but in your first employee example this syntax returned the
matching node, have you tried it?

debugModel.employees.node.(@display == "Employee First Name")

looks like you added another level in your latest example so for that
case this should return the node:

debugModel.group.(@label == "Employees").node.(@label == "Employee First
Name")





On Tue, Apr 15, 2008 at 1:04 PM, Derrick Anderson
<[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote:

thanks guys, i'm sure that my xml is valid, i've refined what i'm trying
to do here a bit

public var debugModel:XML = 
        <mergefields label="Merge Fields">
            <group label="Employees">
                <node label="Employee First Name"
data="Employee_234234-234234-234234-234234" />
                <node label="Employee Last Name"
data="Employee_11111-111111-111111-111111" />
                <node label="Last Performance Note Date"
data="Employee_234234-234234-234234-234234" />
                <node label="Login"
data="Employee_234234-234234-234234-234234" />
                <node label="Login Link"
data="Employee_234234-234234-234234-234234" />
            </group>
...

what i'm trying to do is find any node that has a certain label, like so

var fieldNode:XMLList = debugModel.children().node.(attribute("label")
== "Employee First Name");

and no matter what i try it is not working, what it seems to be doing is
returning me all children of the node i'm looking for (there are none).
if I give that node some arbitrary child nodes, then the node is
returned with it's children, what gives?.

d.






On Tue, Apr 15, 2008 at 1:22 PM, Varun Shetty <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote:

make sure that your xml is wellformed

it did work for me. 
------------------- code ------------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " layout="vertical"
    initialize="runthis();">
    <mx:Script>
        <![CDATA[


            public var debugModel:XML = <mergefields display="Merge
Fields">
            <employees display="Employees">
                <node display="Employee First Name"
data="Employee_234234-234234-234234-234234" />
                <node display="Employee Last Name"
data="Employee_234234-234234-234234-234234" />

                <node display="Employee First Name"
data="Employee_1212121-121212-12121-12112121" />
                <node display="Employee Last Name"
data="Employee_1212121-121212-12121-12112121" />

             </employees>
             </mergefields>;
             
             public function runthis():void {


                 var fieldNode:XMLList =
debugModel.employees.node.(attribute("display") == "Employee First
Name");

                 trace(fieldNode);
             }                
        ]]>
    </mx:Script>
</mx:Application>
------------------- code ------------------------

 

On Tue, Apr 15, 2008 at 11:43 AM, Derrick Anderson
<[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote:

can someone please explain why this does not return an XMLList?

public var debugModel:XML = <mergefields display="Merge Fields">
            <employees display="Employees">
                <node display="Employee First Name"
data="Employee_234234-234234-234234-234234" />
                <node display="Employee Last Name"
data="Employee_234234-234234-234234-234234" />
.....


var fieldNode:XMLList = debugModel.employees.node.(attribute("display")
== "Employee First Name");

but this does...

public var thePeople:XML = <people>
                <person name="Mims Wright" suffix="III">
                    <age>27</age>
                    <aka>Mims H Wright</aka>
                    <aka>Teh AWesoeomes!</aka>
                    <bio></bio>
                </person>
.....

var fieldNode:XMLList = thePeople.person.(attribute("suffix") == "III");

i've tried a million different variations and i cannot get it to work
with my XML- what am i doing wrong here?

thanks,
d.

 

 

 

 

 

Reply via email to