开发者

E4x - getting at the values in Flex

Hello I'm trying to get the values contained in the following XML

 <user>
    <id type="integer">122</id>
    <name>newuser</name>
    <email>newuser@user.com</email>
    <created_at type="datetime">2011-08-31T19:16:52Z</created_at>
    <updated_at type="datetime">2011-08-31T19:16:52Z</updated_at>
    <encrypted_password>8843d7f92416211de9ebb963ff4ce28125932878</encrypted_password>
    <salt>
    b700f04db5bf94929983540a8ceb74a68b4d6ebeb95de04bf9cb0b7e2ad69284
    </salt>
    <admin type="boolean">false</admin>
   开发者_如何转开发 <points type="integer">50</points>
    <address>fdjksljsl</address>
    <address2>fdjkljsflsjl</address2>
    <address3>fdjklls</address3>
    <county>dfjkjlsf</county>
    </user>

So currently I have

<s:HTTPService id="svcSessionCreate" url="/sessions" method="POST" 
                            resultFormat="e4x" result="checkLogin(e)"/>

private function checkLogin(e:ResultEvent):void{
var XMLName:String = XML(e.result).user.name;
var XMLEmail:String = XML(e.result).user.email; 
var XMLPoints:String = XML(e.result).user.points}

But in the debugger I can see that the vars XMLNAME< XMLEMAIL & XMLPoints are all being created but they are empty strings. How can I navigate to their values?

Cheers for you help.

L


XML variable itself stands for root node. So you should omit user the following way:

private function checkLogin(e:ResultEvent):void{
var XMLName:String = XML(e.result).name;
var XMLEmail:String = XML(e.result).email; 
var XMLPoints:String = XML(e.result).points}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜