RE: [flexcoders] Re: How to extract data from XML

2008-05-28 Thread Tracy Spratt
Ah, yes, cool, one more tool in my bag. I did know that text() returned
an XMLList (all expessions do), but never thought to try assigning text
to a specific element.  Thanks.

 

Tracy

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Daniel Freiman
Sent: Tuesday, May 27, 2008 11:32 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Re: How to extract data from XML

 

Technically, text() returns an XMLList where all of the objects are of
kind text.  And you can set the value of those individual nodes in
that list. So for example
text()[0] = value; 
should work.

- Daniel Freiman

On Tue, May 27, 2008 at 2:31 PM, Tracy Spratt [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]  wrote:

Use logo.text();  That returns only the text between those tags.

 

Note that you can't use text() to SET the text node, only to read it.

 

Tracy

 



From: flexcoders@yahoogroups.com mailto:flexcoders@yahoogroups.com
[mailto:flexcoders@yahoogroups.com mailto:flexcoders@yahoogroups.com ]
On Behalf Of wild.katana
Sent: Saturday, May 24, 2008 3:08 AM
To: flexcoders@yahoogroups.com mailto:flexcoders@yahoogroups.com 


Subject: [flexcoders] Re: How to extract data from XML

 

OMFG the namespace was the problem. After I added that line I was able
to call 
Alert.show(myXML.logo.toXMLString()); 
and it worked like a charm. Thanks now I can finally start doing stuff
with my application. This snag has been holding me up for a few days.
One last thing, how would I go about extracting just what is between
the tags logo and /logo instead of the entire element and
attributes? Would I have to convert it to a single XML object first
like you said? Or is there some function that can do that? Thanks for
all your help Tracy, I'm starting to understand how XML works now
because of you.

-Leighton

--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, Tracy Spratt [EMAIL PROTECTED] wrote:

 Ok, you may have a namespace problem. They can be a PITA. I'm not an
 expert and you should reveiw the docs/google if this doesn't work but
 try putting this in the declarations section of your
 app/component(instance scope level):
 
 default xml namespace = http://www.w3.org/2005/Atom
http://www.w3.org/2005/Atom ; 
 
 
 
 There is more stuff in the xmlns declaration in your sample xml:
 
 feed xmlns=http://www.w3.org/2005/Atom http://www.w3.org/2005/Atom
http://www.w3.org/2005/Atom http://www.w3.org/2005/Atom  
 ...
 
 
 
 I do not understand what that second part of the string is. You might
 have to include that as well in the default namespace declaration.
 
 
 
 You can avoid the namespace issue if you use the node index to get a
 node, but this is a very clunky way to do it. To see, try:
 
 Alert.show(myXML.children()[4].toXMLString())
 
 
 
 XMLList always has 0-n xml nodes in it. (the result of an e4x
expression
 is never null) If there is only one node, then many of the XML methods
 will work on it the same as with XML. But for clarity, if I know I
want
 to work with a single XML node then I do:
 
 var myXMLList:XMLList = myXML.logo;
 
 var xmlLogo:XML = myXMLList[0];
 
 
 
 If just you do this below, you will get a datatype error:
 
 var xmlLogo:XML = myXML.logo; //even if that expression returns only a
 single node.
 
 
 
 Tracy
 
 
 
 From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
[mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
] On
 Behalf Of wild.katana
 Sent: Thursday, May 22, 2008 7:08 PM
 To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com 
 Subject: [flexcoders] Re: How to extract data from XML
 
 
 
 Okay, first of all, thanks for all of your help, Tracy. 
 I have checked the myXML variable with Alert.show(myXML) and it shows
 what I pasted in the first post (that's where I got it). So I know
 that myXML contains that. I tried doing
 Alert.show(myXML.logo.toXMLString()) but it is still showing nothing.
 I have read the documentation on using XML and tried many of the
 things it says, but to no avail. One thing I don't wuite understand...
 What is the difference between XML and XMLList? If the myXML.logo
 returns an XMLList, then should I make a variable that contains it
 first? Like 
 var myXMLList:XMLList = myXML.logo;
 Alert.show(myXMLList);
 ?
 I will try that but let me know if that is what you were meaning or
 not... Thanks again..
 
 --- In flexcoders@yahoogroups.com
mailto:flexcoders%40yahoogroups.com
mailto:flexcoders%40yahoogroups.com
mailto:flexcoders%2540yahoogroups.com 
 , Tracy Spratt tspratt@ wrote:
 
  First, did you trace or alert your XML in yur result handler? If you
  did not and are assuming you know what your xml looks like exactly,
do
  that now.
  
  
  
  Second, when attempting to view XML, always use toXMLString()
(search
  the archives for why):
  
  Alert.show(myXML.logo.toXMLString())
  
  
  
  Third, when

RE: [flexcoders] Re: How to extract data from XML

2008-05-27 Thread Tracy Spratt
Use logo.text();  That returns only the text between those tags.

 

Note that you can't use text() to SET the text node, only to read it.

 

Tracy

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of wild.katana
Sent: Saturday, May 24, 2008 3:08 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: How to extract data from XML

 

OMFG the namespace was the problem. After I added that line I was able
to call 
Alert.show(myXML.logo.toXMLString()); 
and it worked like a charm. Thanks now I can finally start doing stuff
with my application. This snag has been holding me up for a few days.
One last thing, how would I go about extracting just what is between
the tags logo and /logo instead of the entire element and
attributes? Would I have to convert it to a single XML object first
like you said? Or is there some function that can do that? Thanks for
all your help Tracy, I'm starting to understand how XML works now
because of you.

-Leighton

--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, Tracy Spratt [EMAIL PROTECTED] wrote:

 Ok, you may have a namespace problem. They can be a PITA. I'm not an
 expert and you should reveiw the docs/google if this doesn't work but
 try putting this in the declarations section of your
 app/component(instance scope level):
 
 default xml namespace = http://www.w3.org/2005/Atom
http://www.w3.org/2005/Atom ; 
 
 
 
 There is more stuff in the xmlns declaration in your sample xml:
 
 feed xmlns=http://www.w3.org/2005/Atom http://www.w3.org/2005/Atom
http://www.w3.org/2005/Atom http://www.w3.org/2005/Atom  
 ...
 
 
 
 I do not understand what that second part of the string is. You might
 have to include that as well in the default namespace declaration.
 
 
 
 You can avoid the namespace issue if you use the node index to get a
 node, but this is a very clunky way to do it. To see, try:
 
 Alert.show(myXML.children()[4].toXMLString())
 
 
 
 XMLList always has 0-n xml nodes in it. (the result of an e4x
expression
 is never null) If there is only one node, then many of the XML methods
 will work on it the same as with XML. But for clarity, if I know I
want
 to work with a single XML node then I do:
 
 var myXMLList:XMLList = myXML.logo;
 
 var xmlLogo:XML = myXMLList[0];
 
 
 
 If just you do this below, you will get a datatype error:
 
 var xmlLogo:XML = myXML.logo; //even if that expression returns only a
 single node.
 
 
 
 Tracy
 
 
 
 From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
[mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
] On
 Behalf Of wild.katana
 Sent: Thursday, May 22, 2008 7:08 PM
 To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com 
 Subject: [flexcoders] Re: How to extract data from XML
 
 
 
 Okay, first of all, thanks for all of your help, Tracy. 
 I have checked the myXML variable with Alert.show(myXML) and it shows
 what I pasted in the first post (that's where I got it). So I know
 that myXML contains that. I tried doing
 Alert.show(myXML.logo.toXMLString()) but it is still showing nothing.
 I have read the documentation on using XML and tried many of the
 things it says, but to no avail. One thing I don't wuite understand...
 What is the difference between XML and XMLList? If the myXML.logo
 returns an XMLList, then should I make a variable that contains it
 first? Like 
 var myXMLList:XMLList = myXML.logo;
 Alert.show(myXMLList);
 ?
 I will try that but let me know if that is what you were meaning or
 not... Thanks again..
 
 --- In flexcoders@yahoogroups.com
mailto:flexcoders%40yahoogroups.com
mailto:flexcoders%40yahoogroups.com
 , Tracy Spratt tspratt@ wrote:
 
  First, did you trace or alert your XML in yur result handler? If you
  did not and are assuming you know what your xml looks like exactly,
do
  that now.
  
  
  
  Second, when attempting to view XML, always use toXMLString()
(search
  the archives for why):
  
  Alert.show(myXML.logo.toXMLString())
  
  
  
  Third, when writing e4x expressions, unless you are very certain of
  yourself, it is best to do it one step at a time, using temporary
XML
  or XMLList variables as needed, and tracing the contained value
using
  toXMLString(). Note that all e4x expressions(myXML.logo is one)
return
  XMLList, not XML. The docs will show how to handle this.
  
  
  
  Fourth, review the XML class in the language Ref and the working
with
  data cha[ter in the developers guide for an explanation on how to
 work
  with XML. The link below is for Flex 2, but the XML stuff has not
  changed.
  
  http://livedocs.adobe.com/flex/2/docs/1910.html
http://livedocs.adobe.com/flex/2/docs/1910.html 
 http://livedocs.adobe.com/flex/2/docs/1910.html
http://livedocs.adobe.com/flex/2/docs/1910.html  
  
  
  
  Tracy
  
  
  
  
  
  From: flexcoders@yahoogroups.com
mailto:flexcoders

Re: [flexcoders] Re: How to extract data from XML

2008-05-27 Thread Daniel Freiman
Technically, text() returns an XMLList where all of the objects are of
kind text.  And you can set the value of those individual nodes in that
list. So for example
text()[0] = value;
should work.

- Daniel Freiman

On Tue, May 27, 2008 at 2:31 PM, Tracy Spratt [EMAIL PROTECTED] wrote:

Use logo.text();  That returns only the text between those tags.



 Note that you can't use text() to SET the text node, only to read it.



 Tracy


  --

 *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On
 Behalf Of *wild.katana
 *Sent:* Saturday, May 24, 2008 3:08 AM
 *To:* flexcoders@yahoogroups.com

 *Subject:* [flexcoders] Re: How to extract data from XML



 OMFG the namespace was the problem. After I added that line I was able
 to call
 Alert.show(myXML.logo.toXMLString());
 and it worked like a charm. Thanks now I can finally start doing stuff
 with my application. This snag has been holding me up for a few days.
 One last thing, how would I go about extracting just what is between
 the tags logo and /logo instead of the entire element and
 attributes? Would I have to convert it to a single XML object first
 like you said? Or is there some function that can do that? Thanks for
 all your help Tracy, I'm starting to understand how XML works now
 because of you.

 -Leighton

 --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Tracy
 Spratt [EMAIL PROTECTED] wrote:
 
  Ok, you may have a namespace problem. They can be a PITA. I'm not an
  expert and you should reveiw the docs/google if this doesn't work but
  try putting this in the declarations section of your
  app/component(instance scope level):
 
  default xml namespace = http://www.w3.org/2005/Atom;;
 
 
 
  There is more stuff in the xmlns declaration in your sample xml:
 
  feed xmlns=http://www.w3.org/2005/Atom http://www.w3.org/2005/Atom 
  ...
 
 
 
  I do not understand what that second part of the string is. You might
  have to include that as well in the default namespace declaration.
 
 
 
  You can avoid the namespace issue if you use the node index to get a
  node, but this is a very clunky way to do it. To see, try:
 
  Alert.show(myXML.children()[4].toXMLString())
 
 
 
  XMLList always has 0-n xml nodes in it. (the result of an e4x expression
  is never null) If there is only one node, then many of the XML methods
  will work on it the same as with XML. But for clarity, if I know I want
  to work with a single XML node then I do:
 
  var myXMLList:XMLList = myXML.logo;
 
  var xmlLogo:XML = myXMLList[0];
 
 
 
  If just you do this below, you will get a datatype error:
 
  var xmlLogo:XML = myXML.logo; //even if that expression returns only a
  single node.
 
 
 
  Tracy
 
  
 
  From: flexcoders@yahoogroups.com flexcoders%40yahoogroups.com [mailto:
 flexcoders@yahoogroups.com flexcoders%40yahoogroups.com] On
  Behalf Of wild.katana
  Sent: Thursday, May 22, 2008 7:08 PM
  To: flexcoders@yahoogroups.com flexcoders%40yahoogroups.com
  Subject: [flexcoders] Re: How to extract data from XML
 
 
 
  Okay, first of all, thanks for all of your help, Tracy.
  I have checked the myXML variable with Alert.show(myXML) and it shows
  what I pasted in the first post (that's where I got it). So I know
  that myXML contains that. I tried doing
  Alert.show(myXML.logo.toXMLString()) but it is still showing nothing.
  I have read the documentation on using XML and tried many of the
  things it says, but to no avail. One thing I don't wuite understand...
  What is the difference between XML and XMLList? If the myXML.logo
  returns an XMLList, then should I make a variable that contains it
  first? Like
  var myXMLList:XMLList = myXML.logo;
  Alert.show(myXMLList);
  ?
  I will try that but let me know if that is what you were meaning or
  not... Thanks again..
 
  --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.commailto:
 flexcoders%40yahoogroups.com flexcoders%2540yahoogroups.com
  , Tracy Spratt tspratt@ wrote:
  
   First, did you trace or alert your XML in yur result handler? If you
   did not and are assuming you know what your xml looks like exactly, do
   that now.
  
  
  
   Second, when attempting to view XML, always use toXMLString() (search
   the archives for why):
  
   Alert.show(myXML.logo.toXMLString())
  
  
  
   Third, when writing e4x expressions, unless you are very certain of
   yourself, it is best to do it one step at a time, using temporary XML
   or XMLList variables as needed, and tracing the contained value using
   toXMLString(). Note that all e4x expressions(myXML.logo is one) return
   XMLList, not XML. The docs will show how to handle this.
  
  
  
   Fourth, review the XML class in the language Ref and the working with
   data cha[ter in the developers guide for an explanation on how to
  work
   with XML. The link below is for Flex 2, but the XML stuff has not
   changed.
  
   http://livedocs.adobe.com/flex/2/docs/1910

[flexcoders] Re: How to extract data from XML

2008-05-24 Thread wild.katana
OMFG the namespace was the problem. After I added that line I was able
to call 
Alert.show(myXML.logo.toXMLString()); 
and it worked like a charm. Thanks now I can finally start doing stuff
with my application. This snag has been holding me up for a few days.
One last thing, how would I go about extracting just what is between
the tags logo and /logo instead of the entire element and
attributes? Would I have to convert it to a single XML object first
like you said? Or is there some function that can do that? Thanks for
all your help Tracy, I'm starting to understand how XML works now
because of you.

-Leighton

--- In flexcoders@yahoogroups.com, Tracy Spratt [EMAIL PROTECTED] wrote:

 Ok, you may have a namespace problem.  They can be a PITA.  I'm not an
 expert and you should reveiw the docs/google if this doesn't work but
 try putting this in the declarations section of your
 app/component(instance scope level):
 
 default xml namespace = http://www.w3.org/2005/Atom;; 
 
  
 
 There is more stuff in the xmlns declaration in your sample xml:
 
 feed xmlns=http://www.w3.org/2005/Atom http://www.w3.org/2005/Atom 
 ...
 
  
 
 I do not understand what that second part of the string is.  You might
 have to include that as well in the default namespace declaration.
 
  
 
 You can avoid the namespace issue if you use the node index to get a
 node, but this is a very clunky way to do it.  To see, try:
 
 Alert.show(myXML.children()[4].toXMLString())
 
  
 
 XMLList always has 0-n xml nodes in it. (the result of an e4x expression
 is never null)  If there is only one node, then many of the XML methods
 will work on it the same as with XML.  But for clarity, if I know I want
 to work with a single XML node then I do:
 
 var myXMLList:XMLList = myXML.logo;
 
 var xmlLogo:XML = myXMLList[0];
 
  
 
 If just you do this below, you will get a datatype error:
 
 var xmlLogo:XML = myXML.logo;  //even if that expression returns only a
 single node.
 
  
 
 Tracy
 
 
 
 From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
 Behalf Of wild.katana
 Sent: Thursday, May 22, 2008 7:08 PM
 To: flexcoders@yahoogroups.com
 Subject: [flexcoders] Re: How to extract data from XML
 
  
 
 Okay, first of all, thanks for all of your help, Tracy. 
 I have checked the myXML variable with Alert.show(myXML) and it shows
 what I pasted in the first post (that's where I got it). So I know
 that myXML contains that. I tried doing
 Alert.show(myXML.logo.toXMLString()) but it is still showing nothing.
 I have read the documentation on using XML and tried many of the
 things it says, but to no avail. One thing I don't wuite understand...
 What is the difference between XML and XMLList? If the myXML.logo
 returns an XMLList, then should I make a variable that contains it
 first? Like 
 var myXMLList:XMLList = myXML.logo;
 Alert.show(myXMLList);
 ?
 I will try that but let me know if that is what you were meaning or
 not... Thanks again..
 
 --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
 , Tracy Spratt tspratt@ wrote:
 
  First, did you trace or alert your XML in yur result handler? If you
  did not and are assuming you know what your xml looks like exactly, do
  that now.
  
  
  
  Second, when attempting to view XML, always use toXMLString() (search
  the archives for why):
  
  Alert.show(myXML.logo.toXMLString())
  
  
  
  Third, when writing e4x expressions, unless you are very certain of
  yourself, it is best to do it one step at a time, using temporary XML
  or XMLList variables as needed, and tracing the contained value using
  toXMLString(). Note that all e4x expressions(myXML.logo is one) return
  XMLList, not XML. The docs will show how to handle this.
  
  
  
  Fourth, review the XML class in the language Ref and the working with
  data cha[ter in the developers guide for an explanation on how to
 work
  with XML. The link below is for Flex 2, but the XML stuff has not
  changed.
  
  http://livedocs.adobe.com/flex/2/docs/1910.html
 http://livedocs.adobe.com/flex/2/docs/1910.html 
  
  
  
  Tracy
  
  
  
  
  
  From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
 [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
 ] On
  Behalf Of wild.katana
  Sent: Thursday, May 22, 2008 4:00 AM
  To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com 
  Subject: [flexcoders] How to extract data from XML
  
  
  
  Hello, I have loaded an XML from a URL using URLLoader. Now that I
  have it in an object, how do I access individual parts of that data?
  The XML looks like this:
  feed xmlns=http://www.w3.org/2005/Atom http://www.w3.org/2005/Atom
 http://www.w3.org/2005/Atom http://www.w3.org/2005/Atom  
  xmlns:openSearch=http://a9.com/-/spec/opensearchrss/1.0/
 http://a9.com/-/spec/opensearchrss/1.0/ 
  http://a9.com/-/spec/opensearchrss/1.0/
 http://a9.com/-/spec/opensearchrss/1.0

RE: [flexcoders] Re: How to extract data from XML

2008-05-23 Thread Tracy Spratt
Ok, you may have a namespace problem.  They can be a PITA.  I'm not an
expert and you should reveiw the docs/google if this doesn't work but
try putting this in the declarations section of your
app/component(instance scope level):

default xml namespace = http://www.w3.org/2005/Atom;; 

 

There is more stuff in the xmlns declaration in your sample xml:

feed xmlns=http://www.w3.org/2005/Atom http://www.w3.org/2005/Atom 
...

 

I do not understand what that second part of the string is.  You might
have to include that as well in the default namespace declaration.

 

You can avoid the namespace issue if you use the node index to get a
node, but this is a very clunky way to do it.  To see, try:

Alert.show(myXML.children()[4].toXMLString())

 

XMLList always has 0-n xml nodes in it. (the result of an e4x expression
is never null)  If there is only one node, then many of the XML methods
will work on it the same as with XML.  But for clarity, if I know I want
to work with a single XML node then I do:

var myXMLList:XMLList = myXML.logo;

var xmlLogo:XML = myXMLList[0];

 

If just you do this below, you will get a datatype error:

var xmlLogo:XML = myXML.logo;  //even if that expression returns only a
single node.

 

Tracy



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of wild.katana
Sent: Thursday, May 22, 2008 7:08 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: How to extract data from XML

 

Okay, first of all, thanks for all of your help, Tracy. 
I have checked the myXML variable with Alert.show(myXML) and it shows
what I pasted in the first post (that's where I got it). So I know
that myXML contains that. I tried doing
Alert.show(myXML.logo.toXMLString()) but it is still showing nothing.
I have read the documentation on using XML and tried many of the
things it says, but to no avail. One thing I don't wuite understand...
What is the difference between XML and XMLList? If the myXML.logo
returns an XMLList, then should I make a variable that contains it
first? Like 
var myXMLList:XMLList = myXML.logo;
Alert.show(myXMLList);
?
I will try that but let me know if that is what you were meaning or
not... Thanks again..

--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, Tracy Spratt [EMAIL PROTECTED] wrote:

 First, did you trace or alert your XML in yur result handler? If you
 did not and are assuming you know what your xml looks like exactly, do
 that now.
 
 
 
 Second, when attempting to view XML, always use toXMLString() (search
 the archives for why):
 
 Alert.show(myXML.logo.toXMLString())
 
 
 
 Third, when writing e4x expressions, unless you are very certain of
 yourself, it is best to do it one step at a time, using temporary XML
 or XMLList variables as needed, and tracing the contained value using
 toXMLString(). Note that all e4x expressions(myXML.logo is one) return
 XMLList, not XML. The docs will show how to handle this.
 
 
 
 Fourth, review the XML class in the language Ref and the working with
 data cha[ter in the developers guide for an explanation on how to
work
 with XML. The link below is for Flex 2, but the XML stuff has not
 changed.
 
 http://livedocs.adobe.com/flex/2/docs/1910.html
http://livedocs.adobe.com/flex/2/docs/1910.html 
 
 
 
 Tracy
 
 
 
 
 
 From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
[mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
] On
 Behalf Of wild.katana
 Sent: Thursday, May 22, 2008 4:00 AM
 To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com 
 Subject: [flexcoders] How to extract data from XML
 
 
 
 Hello, I have loaded an XML from a URL using URLLoader. Now that I
 have it in an object, how do I access individual parts of that data?
 The XML looks like this:
 feed xmlns=http://www.w3.org/2005/Atom http://www.w3.org/2005/Atom
http://www.w3.org/2005/Atom http://www.w3.org/2005/Atom  
 xmlns:openSearch=http://a9.com/-/spec/opensearchrss/1.0/
http://a9.com/-/spec/opensearchrss/1.0/ 
 http://a9.com/-/spec/opensearchrss/1.0/
http://a9.com/-/spec/opensearchrss/1.0/  
 xmlns:gml=http://www.opengis.net/gml http://www.opengis.net/gml
http://www.opengis.net/gml http://www.opengis.net/gml  
 xmlns:georss=http://www.georss.org/georss
http://www.georss.org/georss 
 http://www.georss.org/georss http://www.georss.org/georss  
 xmlns:media=http://search.yahoo.com/mrss/
http://search.yahoo.com/mrss/ 
 http://search.yahoo.com/mrss/ http://search.yahoo.com/mrss/  
 xmlns:yt=http://gdata.youtube.com/schemas/2007
http://gdata.youtube.com/schemas/2007 
 http://gdata.youtube.com/schemas/2007
http://gdata.youtube.com/schemas/2007  
 xmlns:gd=http://schemas.google.com/g/2005
http://schemas.google.com/g/2005 
 http://schemas.google.com/g/2005 http://schemas.google.com/g/2005 

 idhttp://gdata.youtube.com/feeds/api/videos
http://gdata.youtube.com/feeds/api/videos 
 http://gdata.youtube.com/feeds

[flexcoders] Re: How to extract data from XML

2008-05-22 Thread wild.katana
Okay, first of all, thanks for all of your help, Tracy. 
I have checked the myXML variable with Alert.show(myXML) and it shows
what I pasted in the first post (that's where I got it). So I know
that myXML contains that. I tried doing
Alert.show(myXML.logo.toXMLString()) but it is still showing nothing.
I have read the documentation on using XML and tried many of the
things it says, but to no avail. One thing I don't wuite understand...
What is the difference between XML and XMLList? If the myXML.logo
returns an XMLList, then should I make a variable that contains it
first? Like 
var myXMLList:XMLList = myXML.logo;
Alert.show(myXMLList);
?
I will try that but let me know if that is what you were meaning or
not... Thanks again..

--- In flexcoders@yahoogroups.com, Tracy Spratt [EMAIL PROTECTED] wrote:

 First, did you trace or alert your XML in yur result handler?  If you
 did not and are assuming you know what your xml looks like exactly, do
 that now.
 
  
 
 Second, when attempting to view XML, always use toXMLString() (search
 the archives for why):
 
 Alert.show(myXML.logo.toXMLString())
 
  
 
 Third, when writing e4x expressions, unless you are very certain of
 yourself, it is best to do it one step at a time, using  temporary XML
 or XMLList variables as needed, and tracing the contained value using
 toXMLString().  Note that all e4x expressions(myXML.logo is one) return
 XMLList, not XML. The docs will show how to handle this.
 
  
 
 Fourth, review the XML class in the language Ref and the working with
 data cha[ter in the developers guide for an explanation on how to work
 with XML.  The link below is for Flex 2, but the XML stuff has not
 changed.
 
 http://livedocs.adobe.com/flex/2/docs/1910.html
 
  
 
 Tracy
 
  
 
 
 
 From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
 Behalf Of wild.katana
 Sent: Thursday, May 22, 2008 4:00 AM
 To: flexcoders@yahoogroups.com
 Subject: [flexcoders] How to extract data from XML
 
  
 
 Hello, I have loaded an XML from a URL using URLLoader. Now that I
 have it in an object, how do I access individual parts of that data?
 The XML looks like this:
 feed xmlns=http://www.w3.org/2005/Atom http://www.w3.org/2005/Atom 
 xmlns:openSearch=http://a9.com/-/spec/opensearchrss/1.0/
 http://a9.com/-/spec/opensearchrss/1.0/ 
 xmlns:gml=http://www.opengis.net/gml http://www.opengis.net/gml 
 xmlns:georss=http://www.georss.org/georss
 http://www.georss.org/georss 
 xmlns:media=http://search.yahoo.com/mrss/
 http://search.yahoo.com/mrss/ 
 xmlns:yt=http://gdata.youtube.com/schemas/2007
 http://gdata.youtube.com/schemas/2007 
 xmlns:gd=http://schemas.google.com/g/2005
 http://schemas.google.com/g/2005 
 idhttp://gdata.youtube.com/feeds/api/videos
 http://gdata.youtube.com/feeds/api/videos /id
 updated2008-05-22T07:54:46.868Z/updated
 category scheme=http://schemas.google.com/g/2005#kind
 http://schemas.google.com/g/2005#kind 
 term=http://gdata.youtube.com/schemas/2007#video
 http://gdata.youtube.com/schemas/2007#video /
 title type=textYouTube Videos matching query: football
 -soccer/title
 logohttp://www.youtube.com/img/pic_youtubelogo_123x63.gif
 http://www.youtube.com/img/pic_youtubelogo_123x63.gif /logo
 link rel=alternate type=text/html href=http://www.youtube.com
 http://www.youtube.com /
 link rel=http://schemas.google.com/g/2005#feed
 http://schemas.google.com/g/2005#feed 
 type=application/atom+xml
 href=http://gdata.youtube.com/feeds/api/videos
 http://gdata.youtube.com/feeds/api/videos /
 link rel=self type=application/atom+xml
 href=http://gdata.youtube.com/feeds/api/videos?start-index=11amp;max-r
 esults=10amp;orderby=publishedamp;vq=football+-soccer
 http://gdata.youtube.com/feeds/api/videos?start-index=11amp;max-result
 s=10amp;orderby=publishedamp;vq=football+-soccer /
 link rel=previous type=application/atom+xml
 href=http://gdata.youtube.com/feeds/api/videos?start-index=1amp;max-re
 sults=10amp;orderby=publishedamp;vq=football+-soccer
 http://gdata.youtube.com/feeds/api/videos?start-index=1amp;max-results
 =10amp;orderby=publishedamp;vq=football+-soccer /
 link rel=next type=application/atom+xml
 href=http://gdata.youtube.com/feeds/api/videos?start-index=21amp;max-r
 esults=10amp;orderby=publishedamp;vq=football+-soccer
 http://gdata.youtube.com/feeds/api/videos?start-index=21amp;max-result
 s=10amp;orderby=publishedamp;vq=football+-soccer /
 author
 nameYouTube/name
 urihttp://www.youtube.com/ http://www.youtube.com/ /uri
 /author
 ...
 
 So let's say I wanted to access the information in the logo element,
 how would I do this? My code looks like this:
 
 public var myLoader:URLLoader; //declare this outside of a function.
 The leading underscore is just a convention
 public var myXML:XML; //this too
 
 private function initUrlLoader():void {
 
 var XML_URL:String
 =http://gdata.youtube.com/feeds/api/videos?vq=football+-soccerorderby=
 publishedstart-index=11max-results=10