I’ve noticed that when I set a variable equal to the xml you gave, I had to 
remove any attributes with the : in the name in order to parse it with e4x.

For example, I tried to simply Alert.show(“status xml: “ + thexml.Status); and 
that would not work until I removed the : namespacing attributes like so:

<rdf>

 <Status >

  <statusCode

      

      >3</statusCode>

  <presence lang="NUM">3</presence>

  <presence lang="en">Away</presence>

  <presence lang="fr">Absent</presence>

  <presence lang="de">Abwesend</presence>

 

 

  <presence lang="ja">一時退席中</presence>

  <presence lang="zh-cn">暫時離開</presence>

  <presence lang="zh-tw">离开</presence>

  <presence lang="pt">Ausente</presence>

  <presence lang="pt-br">Ausente</presence>

  <presence lang="it">Torno subito</presence>

 

 

  <presence lang="es">Ausente</presence>

  <presence lang="pl">Zaraz wracam</presence>

  <presence lang="se">Tillfälligt borta</presence>

 </Status>

</rdf>

 

If what you posted previously works, I’m surprised. I initially coded a sample 
to show what you could do instead, and then had to troubleshoot it, as it 
wasn’t working.

With the above xml, the following works:

 

if(testxml.Status.presence.(@lang=="en")!="Offline")

{

// do whatever you need to do if they aren’t offline

}

 

var status:String = testxml.Status.presence.(@lang=="en");

 

mx.controls.Alert.show("status: " + status);

 

Hope this helps a bit, I’m not really sure how to handle the namespaces with 
e4x or why I can’t do basic e4x queries when they are present. =(

 

Seth

 

  _____  

From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Toby 
Tremayne
Sent: Tuesday, September 25, 2007 12:47 AM
To: [email protected]
Subject: [flexcoders] e4x question

 

hi all - i'm trying to get the english status from a skype status xml (below).  
What I'm not sure how to deal with is the xml:lang attribute.  I'm sure there's 
a clever way to set the namespace and use e4x to get out the one i want 

but i'm not sure how.  I ended up doing this:

 

for (i=0; i < event.result.RDF.Status.presence.length; i++) {

                                                            if 
(event.result.RDF.Status.presence[i]["xml:lang"] == "en") {

                                                                        if 
(event.result.RDF.Status.presence[i]["value"] != "Offline") {

                                                                                
    status = "Online";

                                                                        }

                                                                        break;

                                                            }

                                                }

 

can anyone tell me a cleaner way to do it perhaps using e4x please?  I suspect 
my e4x attempts were misguided.

 

Toby

 

 

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

<rdf:RDF 

            xmlns:rdf="http://www.w3. 
<http://www.w3.org/1999/02/22-rdf-syntax-ns> org/1999/02/22-rdf-syntax-ns#"

            xmlns:dcq="http://purl. <http://purl.org/dc/terms/> org/dc/terms/"

            xmlns="http://www.skype. <http://www.skype.com/go/skypeweb> 
com/go/skypeweb"

> 

 <Status rdf:about="urn:skype:skype.com:skypeweb/1.1">

  <statusCode

            rdf:datatype="http://www.skype. <http://www.skype.com/go/skypeweb> 
com/go/skypeweb"

            >3</statusCode>

  <presence xml:lang="NUM">3</presence>

  <presence xml:lang="en">Away</presence>

  <presence xml:lang="fr">Absent</presence>

  <presence xml:lang="de">Abwesend</presence>

 

  <presence xml:lang="ja">一時退席中</presence>

  <presence xml:lang="zh-cn">暫時離開</presence>

  <presence xml:lang="zh-tw">离开</presence>

  <presence xml:lang="pt">Ausente</presence>

  <presence xml:lang="pt-br">Ausente</presence>

  <presence xml:lang="it">Torno subito</presence>

 

  <presence xml:lang="es">Ausente</presence>

  <presence xml:lang="pl">Zaraz wracam</presence>

  <presence xml:lang="se">Tillfälligt borta</presence>

 </Status>

</rdf:RDF>

 

 

 

 

 

 

 

 

 

 

-----------------------------------

 

                Life is poetry, write it in your own words

 

-----------------------------------

 

Toby Tremayne

IT Director

Code Poet and Zen Master of the Heavy Sleep

Codename:Tuesday

02 8012 0953

0416 048 090

ICQ: 13107913

 





 

 

Reply via email to