Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

More xml parsing in actionscript 2

Posted on 2009-12-16
1
Medium Priority
?
337 Views
Last Modified: 2013-11-11
Hi,
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="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://www.oakapple.somdomain.com/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(){
trace(responseXML);
}


responseXML.onLoad = onLoaded;

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

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:loginResponse xmlns:ns2="http://www.oakapple.somedomain.com/soap/"><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.
thanks
0
Comment
Question by:palpsdelux
1 Comment
 
LVL 19

Accepted Solution

by:
moagrius earned 2000 total points
ID: 26061505
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];
trace(thatXMLNode.attributes.sessionToken);
trace(thatXMLNode.attributes.email);
trace(thatXMLNode.attributes.mobile);
// etc...

Open in new window

0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
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,…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
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.
Suggested Courses

564 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