More xml parsing in actionscript 2

Posted on 2009-12-16
Last Modified: 2013-11-11
I have some code that is successfully sending a request to a server and getting a response in the form of some xml.  what I'm now trying to do is extract the bits of data from the return to use in my app.  The code thus far is:

var serverURL = 'http://someserver/oakapple/Addy';

XMLString = ('<soapenv:Envelope xmlns:soapenv="" xmlns:soap=""><soapenv:Header/><soapenv:Body><soap:login username="username" password="password"/></soapenv:Body></soapenv:Envelope>');

var SearchRequestXML:XML = new XML(XMLString);

//Create the container for the response
var responseXML:XML = new XML();

SearchRequestXML.sendAndLoad(serverURL, responseXML);

function onLoaded(){

responseXML.onLoad = onLoaded;

Now, running the above code gives me an expected trace of this:

<soap:Envelope xmlns:soap=""><soap:Body><ns2:loginResponse xmlns:ns2=""><data sessionToken="934d1c717c8c7dca01fdf98269158d46" email="test123" mobile="test123" lastname="test123" firstname="test123" /></ns2:loginResponse></soap:Body></soap:Envelope>

So what I want to do now is get the values in the above mentioned return.

Many thanks

//*********************** Updated

Using this code:

xml1 = responseXML.childNodes[0].childNodes[0].childNodes[0].childNodes;

I can now trace this:

<data sessionToken="c81930a0396aa9122226c17c7daba775" email="test123" mobile="test123" lastname="test123" firstname="test123" />

but am still having problems getting the values from this piece.
Question by:palpsdelux
    1 Comment
    LVL 19

    Accepted Solution

    that node would be childNodes[0].childNodes[0].childNodes[0].childNodes[0];

    then each attribute would be accessed by using thatXMLNode.attributes.whatever

    like so
    var thatXMLNode:XML = responseXML.childNodes[0].childNodes[0].childNodes[0].childNodes[0];
    // etc...

    Open in new window


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
    I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
    In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
    The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now