Re: [Flashcoders] RE: retreieving a node that contains a specific attribute from an XML list
You can pick nodes by adding a comparison into your XML path Conteudo.(@id == link) will give you the correct node too Sent from my iPhone On 13 Sep 2009, at 22:09, Isaac Alves wrote: Hi, thank you all. I've managed to do it like this, based on what Cor wrote me: function clickItemTitle(e:Event):void { _link = String(e.target.frameLink); var node:int; for (var i:Number = 0; i < conteudo.length(); i++) { if (conteudo[...@id == _link) { node = i; } } trace ("node: " + node); then I just use conteudo[node] to access the content. I was trying to do that without using a for loop , but maybe it wouldn't be possible. anyway I believe there's no need to avoid a loop here, even if there's 1200 nodes in my XML, right? Allandt, I actually didn't understand the use of toXMLString(), at least in this situation.. cheers! isaac -- Message: 5 Date: Sun, 13 Sep 2009 12:44:10 +0100 From: allandt bik-elliott Subject: Re: [Flashcoders] retreieving a node that contains a specific attribute from an XML list. To: Flash Coders List Message-ID: <51f4e795-f48c-4c62-8ffd-586daafb1...@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes also if you're tracing xml, you could try trace(myXML.toXMLString()); which will make sure that even the root node of the xml is traced a On 13 Sep 2009, at 06:39, Cor wrote: Try this: trace (conteudo.slide[...@id); trace (conteudo.slide[...@id); trace (conteudo.slide[0].tit); -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Isaac Alves Sent: zondag 13 september 2009 2:00 To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] retreieving a node that contains a specific attribute from an XML list. I have an XMLList and I would like to retrieve a node in this list that contain a specfic attribute. here is how my XMLlist "conteudo" is organized. trace (conteudo) throws: Apresentação (lots of text...) Apresentação (lots of text...) etc... I've tried the following ways: //gets all nodes that contain the attribue "id". that is , the same as trace(conteudo), cause every node contain an // "id" attribute. i don't need them all to contain the attribute, but i've made so, trying to avoid errors. so there a lot of // nodes in which the "id" attribute is equal to "" . //trace (conteudo.(hasOwnProperty("@id")); //this one doesn't throws an error, but doesn't retrieve anything //trace (conteudo.(hasOwnProperty("@id" == "apresentacao"))); //throws the error: ReferenceError: Error #1065: A variá vel apresentacao não foi definida. (variable not defined) //trace (conteudo.(hasOwnProperty("@id" == apresentacao))); // same reference error... //trace (conteudo.(hasOwnProperty(@id == "apresentacao"))); // why it doesn't work like this? same reference errpr //trace ("node i want: " + conteudo.(@id == "apresentacao")); // this one doesn't throws an error, but doesn't retrieve anything //trace ("vamo ve: " + conteudo.("@id" == "apresentacao")); //throws all the attributes "@id" that exist inside the xmllist, concatenated //trace ("" + conteu...@id); //again, here it throws all the attributes "@id" that exist inside the xmllist , concatenated //if (conteudo.(hasOwnProperty("@id" == "apresentacao"))) //{ //trace ("tem o id: "); //trace (conteu...@id); //} help please!! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] RE: retreieving a node that contains a specific attribute from an XML list
Hi, thank you all. I've managed to do it like this, based on what Cor wrote me: function clickItemTitle(e:Event):void { _link = String(e.target.frameLink); var node:int; for (var i:Number = 0; i < conteudo.length(); i++) { if (conteudo[...@id == _link) { node = i; } } trace ("node: " + node); then I just use conteudo[node] to access the content. I was trying to do that without using a for loop , but maybe it wouldn't be possible. anyway I believe there's no need to avoid a loop here, even if there's 1200 nodes in my XML, right? Allandt, I actually didn't understand the use of toXMLString(), at least in this situation.. cheers! isaac -- Message: 5 Date: Sun, 13 Sep 2009 12:44:10 +0100 From: allandt bik-elliott Subject: Re: [Flashcoders] retreieving a node that contains a specific attribute from an XML list. To: Flash Coders List Message-ID: <51f4e795-f48c-4c62-8ffd-586daafb1...@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes also if you're tracing xml, you could try trace(myXML.toXMLString()); which will make sure that even the root node of the xml is traced a On 13 Sep 2009, at 06:39, Cor wrote: > Try this: > > trace (conteudo.slide[...@id); > trace (conteudo.slide[...@id); > trace (conteudo.slide[0].tit); > > > > -Original Message- > From: flashcoders-boun...@chattyfig.figleaf.com > [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of > Isaac Alves > Sent: zondag 13 september 2009 2:00 > To: flashcoders@chattyfig.figleaf.com > Subject: [Flashcoders] retreieving a node that contains a specific > attribute > from an XML list. > > I have an XMLList and I would like to retrieve a node in this list > that contain a specfic attribute. > > here is how my XMLlist "conteudo" is organized. trace (conteudo) > throws: > > > Apresentação > (lots of text...) > > > Apresentação > (lots of text...) > > etc... > > I've tried the following ways: > > //gets all nodes that contain the attribue "id". that is , the same > as trace(conteudo), cause every node contain an > // "id" attribute. i don't need them all to contain the > attribute, but i've made so, trying to avoid errors. so there a lot of > // nodes in which the "id" attribute is equal to "" . > //trace (conteudo.(hasOwnProperty("@id")); > > //this one doesn't throws an error, but doesn't retrieve anything > //trace (conteudo.(hasOwnProperty("@id" == "apresentacao"))); > > //throws the error: ReferenceError: Error #1065: A variável > apresentacao não foi definida. (variable not defined) > //trace (conteudo.(hasOwnProperty("@id" == apresentacao))); > > // same reference error... > //trace (conteudo.(hasOwnProperty(@id == "apresentacao"))); > > // why it doesn't work like this? same reference errpr > //trace ("node i want: " + conteudo.(@id == "apresentacao")); > > // this one doesn't throws an error, but doesn't retrieve > anything > //trace ("vamo ve: " + conteudo.("@id" == "apresentacao")); > > //throws all the attributes "@id" that exist inside the xmllist, > concatenated > //trace ("" + conteu...@id); > > //again, here it throws all the attributes "@id" that exist inside > the xmllist , concatenated > //if (conteudo.(hasOwnProperty("@id" == "apresentacao"))) > //{ > //trace ("tem o id: "); > //trace (conteu...@id); > //} > > help please!! > > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders