tags:

views:

528

answers:

1

i used httpservice for read xml get full xml but i want particular xml fled value only like first node id only how can i split xml ?

<mx:HTTPService result="getid(event)"  id="xml_coupon" url="###" useProxy="false" resultFormat="e4x"/>

public function getid((evt:ResultEvent):void

   {
    var id:number=evt.result.id;
                  Alert.show(id.tostring);


   }

show all id but i want first index id only . how can i read ? i tried Alert.show(evt.getChildAt(1).id); but show some error .if you know refer me ?

+2  A: 

hey do some thing like this

if xml is like this

<mx:XML id="usersXML">
  <root>
    <users>
      <user id="1" lovesDonuts="Yes">
        <firstname>Tariq</firstname>
        <lastname>Ahmed</lastname>
      </user>
      <user id="2" lovesDonuts="Yes">
        <firstname>Jon</firstname>
        <lastname>Hirschi</lastname>
      </user>
    </users>
  </root>
</mx:XML>

then do this

usersXML.users.user[1].firstname

for id

usersXML.users.user[1].@id
Rahul Garg
This is the right idea, but so there is no confusion, you are returning "Jon" and "2", not "Tariq" and "1". The first user is the [0] index.
Glenn
yes it shud be [0]
Rahul Garg
thank you rahul
R.Vijayakumar
hey welcome you recommend you to go through chapter 15 of Flex 3 in action for more tricks of E4X
Rahul Garg