Xml namespaces make it so that different xml structures can work
together, even if they use the same tag names.  Essentially what happens
is that every tag gets prefixed with the namespace string.  So when you
see "<Trackpoint>" to the parser it is really
"<http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v1:Trackpoint>
"

 

If you imported some xml from that source into some of yours, the
namespace would ensure that you could use "<Trackpoint>" as a node name,
and it would not conflict whith the imported xml node.

 

Even though it looks like a link it is not treated that way. It is just
a string that you can be pretty sure no one else uses for their
namespace.  It is just a convention to use a string that looks like an
url.

 

The failure of the ".." syntax is boggling.  There is probably a
reasonable explanation, but I don't know it.  I am getting used to
finding alternate paths when one is blocked.

 

Tracy

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Nate Pearson
Sent: Thursday, April 17, 2008 7:23 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Problems walking XML file with E4X

 

Thanks! That makes me feel a lot better that Tracy couldn't figure it
out either with the .. method :).

Why do you have to register the namespace? I've never understood what
that does, plus that link doesn't even work.

Thanks again!

-Nate

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
, "Tracy Spratt" <[EMAIL PROTECTED]> wrote:
>
> Two things:
> 
> 1. xml namespace: The xml has namespace specified, so yo need to d:
> 
> default xml namespace =
> "http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v1
<http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v1> ";
> 
> 
> 
> 2. I do not understand why the ".." did not work, but this does: 
> 
> var myXML2:XMLList = dataSet.descendants("Trackpoint");
> 
> 
> 
> Tracy
> 
> ________________________________
> 
> From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
[mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of Nate Pearson
> Sent: Thursday, April 17, 2008 4:44 PM
> To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> 
> Subject: [flexcoders] Re: Problems walking XML file with E4X
> 
> 
> 
> It's an air app but that shouldn't matter. If you download the file
> bellow and put it in data/frankTT.xml you can try it too.
> 
> I was inspecting my XML through the debugger, but I think you want me
> to do it this way.
> 
> Here it is:
> 
> <?xml version="1.0" encoding="utf-8"?>
> <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> 
> <http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> > "
> layout="absolute" creationComplete="onInit()">
> <mx:XML id="dataSet" source="data/frankTT.xml" format="e4x" />
> <mx:Script>
> <![CDATA[
> 
> private function onInit():void{
> 
> var myXML2:XMLList = dataSet..Trackpoint
> trace(myXML2.toXMLString());
> }
> ]]>
> </mx:Script>
> <mx:Panel>
> 
> </mx:Panel>
> 
> </mx:WindowedApplication>
> 
> --- In flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com>
<mailto:flexcoders%40yahoogroups.com>
> , "Tracy Spratt" <tspratt@> wrote:
> >
> > Just to be sure, you are using toXMLString() to inspect the xml,
> > correct?
> > 
> > 
> > 
> > In fact, post the code where you are examining myXMLList.
> > 
> > 
> > 
> > Tracy
> > 
> > 
> > 
> > ________________________________
> > 
> > From: flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com>
<mailto:flexcoders%40yahoogroups.com>
> [mailto:flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com>
<mailto:flexcoders%40yahoogroups.com>
> ] On
> > Behalf Of Nate Pearson
> > Sent: Thursday, April 17, 2008 4:19 PM
> > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
<mailto:flexcoders%40yahoogroups.com> 
> > Subject: [flexcoders] Re: Problems walking XML file with E4X
> > 
> > 
> > 
> > The trace shows all the data.
> > 
> > The other one doesn't work. I can see in the file that the case is
> > "Trackpoint". Could it have to do with how it's nested?
> > 
> > --- In flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com> 
> <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com>
> > , "Tracy Spratt" <tspratt@> wrote:
> > >
> > > Skip this:
> > > 
> > > var myXML:XML = dataSet[0]; //dataSet is aleady XML
> > > 
> > > 
> > > 
> > > Do: 
> > > 
> > > trace(dataSet.toXMLString()); // USE toXMLString() always with xml
> > > 
> > > 
> > > 
> > > Try:
> > > 
> > > var myXMLList:XMLList = dataSet..Trackpoint; //NOTE CASE of
> TrackPoint
> > > 
> > > 
> > > 
> > > Tracy
> > > 
> > > 
> > > 
> > > ________________________________
> > > 
> > > From: flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com> 
> <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com>
> > [mailto:flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com> 
> <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com>
> > ] On
> > > Behalf Of Nate Pearson
> > > Sent: Thursday, April 17, 2008 4:07 PM
> > > To: flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com>
<mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com> 
> > > Subject: [flexcoders] Problems walking XML file with E4X
> > > 
> > > 
> > > 
> > > So I'm new to this whole xml thing (i usually use objects).
> > > 
> > > I have this xml file:
> > >
> >
>
http://trail.motionbased.com/trail/export.mb?episodePkValues=5413584&tra
<http://trail.motionbased.com/trail/export.mb?episodePkValues=5413584&tr
a> 
>
<http://trail.motionbased.com/trail/export.mb?episodePkValues=5413584&tr
<http://trail.motionbased.com/trail/export.mb?episodePkValues=5413584&tr
> 
> a> 
> >
>
<http://trail.motionbased.com/trail/export.mb?episodePkValues=5413584&tr
<http://trail.motionbased.com/trail/export.mb?episodePkValues=5413584&tr
> 
>
<http://trail.motionbased.com/trail/export.mb?episodePkValues=5413584&tr
<http://trail.motionbased.com/trail/export.mb?episodePkValues=5413584&tr
> 
> > 
> > a> 
> > > iningCenterExport.courseMode=true
> > >
> >
>
<http://trail.motionbased.com/trail/export.mb?episodePkValues=5413584&tr
<http://trail.motionbased.com/trail/export.mb?episodePkValues=5413584&tr
> 
>
<http://trail.motionbased.com/trail/export.mb?episodePkValues=5413584&tr
<http://trail.motionbased.com/trail/export.mb?episodePkValues=5413584&tr
> 
> > 
> >
>
<http://trail.motionbased.com/trail/export.mb?episodePkValues=5413584&tr
<http://trail.motionbased.com/trail/export.mb?episodePkValues=5413584&tr
> 
>
<http://trail.motionbased.com/trail/export.mb?episodePkValues=5413584&tr
<http://trail.motionbased.com/trail/export.mb?episodePkValues=5413584&tr
> 
> > 
> > > 
> > > ainingCenterExport.courseMode=true> 
> > > 
> > > The structure is like this:
> > > <TrainingCenterDatabase>
> > > <Courses>
> > > <CourseFolder>
> > > <Course>
> > > <Track>
> > > <Trackpoint/>
> > > <Trackpoint/>
> > > <Trackpoint/>
> > > 
> > > I want to get to the Trackpoint data.
> > > 
> > > In my App I have (I renamed the file):
> > > <mx:XML id="dataSet" source="data/frankTT.xml" format="e4x" />
> > > 
> > > Then to put it into an XMLList I go:
> > > var myXML:XML = dataSet[0]
> > > var myXMLList:XMLList = myXML..TrackPoint
> > > 
> > > That doesn't work though, myXMLList is empty! How do I walk this
> file?
> > > 
> > > Thanks!
> > > 
> > > Nate
> > >
> >
>

 

Reply via email to