[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

jquery of javascript parse xml

Posted on 2013-05-17
2
Medium Priority
?
574 Views
Last Modified: 2013-05-17
Hi,
I have a webservice response that comes back as xml text.  Can someone please tell me how to make a function (or statment) that can get

session-id out of this string?

<?xml version="1.0"?><amtd><result>OK</result><xml-log-in><session-id>83D7D6CB23366AE5BF6D2846000FD71F.5krocvxvOyOCZsGalRLdzQ</session-id><user-id>xxxxxx</user-id><cdi>dddddd</cdi><timeout>55</timeout><login-time>2013-05-17 16:05:55 EDT</login-time><associated-account-id>xxxxxx</associated-account-id><nyse-quotes>realtime</nyse-quotes><nasdaq-quotes>realtime</nasdaq-quotes><opra-quotes>realtime</opra-quotes><amex-quotes>realtime</amex-quotes><cme-quotes>delayed</cme-quotes><ice-quotes>delayed</ice-quotes><forex-quotes>delayed</forex-quotes><exchange-status>non-professional</exchange-status><authorizations><options360>false</options360></authorizations><accounts><account><account-id>xxxxxx</account-id><display-name>xxxxxx</display-name><cdi>dddddddd</cdi><description>xxxx MILLMAN</description><associated-account>true</associated-account><company>AMER</company><segment>ADVNCED</segment><unified>true</unified><preferences><express-trading>false</express-trading><option-direct-routing>false</option-direct-routing><stock-direct-routing>false</stock-direct-routing></preferences><authorizations><apex>true</apex><level2>true</level2><stock-trading>true</stock-trading><margin-trading>true</margin-trading><streaming-news>true</streaming-news><option-trading>full</option-trading><streamer>true</streamer><advanced-margin>true</advanced-margin></authorizations></account><account><account-id>ddddd</account-id><display-name>xxxxxxroth</display-name><cdi>ddddd</cdi><description>xxx TD</description><associated-account>false</associated-account><company>AMER</company><segment>ADVNCED</segment><unified>true</unified><preferences><express-trading>false</express-trading><option-direct-routing>false</option-direct-routing><stock-direct-routing>false</stock-direct-routing></preferences><authorizations><apex>true</apex><level2>true</level2><stock-trading>true</stock-trading><margin-trading>true</margin-trading><streaming-news>true</streaming-news><option-trading>spread</option-trading><streamer>true</streamer><advanced-margin>true</advanced-margin></authorizations></account><account><account-id>dddddddd</account-id><display-name>xxxxxxira</display-name><cdi>dddddd</cdi><description>xxxxxx IRA</description><associated-account>false</associated-account><company>AMER</company><segment>ADVNCED</segment><unified>true</unified><preferences><express-trading>false</express-trading><option-direct-routing>false</option-direct-routing><stock-direct-routing>false</stock-direct-routing></preferences><authorizations><apex>true</apex><level2>true</level2><stock-trading>true</stock-trading><margin-trading>true</margin-trading><streaming-news>true</streaming-news><option-trading>spread</option-trading><streamer>true</streamer><advanced-margin>true</advanced-margin></authorizations></account></accounts></xml-log-in></amtd>
0
Comment
Question by:jackjohnson44
2 Comments
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 39176125
test page : http://jsfiddle.net/YYT6J/2/
Using : http://api.jquery.com/jQuery.parseXML/
var xml= "<?xml version=\"1.0\"?><amtd><result>OK</result><xml-log-in><session-id>83D7D6CB23366AE5BF6D2846000FD71F.5krocvxvOyOCZsGalRLdzQ</session-id><user-id>xxxxxx</user-id><cdi>dddddd</cdi><timeout>55</timeout><login-time>2013-05-17 16:05:55 EDT</login-time><associated-account-id>xxxxxx</associated-account-id><nyse-quotes>realtime</nyse-quotes><nasdaq-quotes>realtime</nasdaq-quotes><opra-quotes>realtime</opra-quotes><amex-quotes>realtime</amex-quotes><cme-quotes>delayed</cme-quotes><ice-quotes>delayed</ice-quotes><forex-quotes>delayed</forex-quotes><exchange-status>non-professional</exchange-status><authorizations><options360>false</options360></authorizations><accounts><account><account-id>xxxxxx</account-id><display-name>xxxxxx</display-name><cdi>dddddddd</cdi><description>xxxx MILLMAN</description><associated-account>true</associated-account><company>AMER</company><segment>ADVNCED</segment><unified>true</unified><preferences><express-trading>false</express-trading><option-direct-routing>false</option-direct-routing><stock-direct-routing>false</stock-direct-routing></preferences><authorizations><apex>true</apex><level2>true</level2><stock-trading>true</stock-trading><margin-trading>true</margin-trading><streaming-news>true</streaming-news><option-trading>full</option-trading><streamer>true</streamer><advanced-margin>true</advanced-margin></authorizations></account><account><account-id>ddddd</account-id><display-name>xxxxxxroth</display-name><cdi>ddddd</cdi><description>xxx TD</description><associated-account>false</associated-account><company>AMER</company><segment>ADVNCED</segment><unified>true</unified><preferences><express-trading>false</express-trading><option-direct-routing>false</option-direct-routing><stock-direct-routing>false</stock-direct-routing></preferences><authorizations><apex>true</apex><level2>true</level2><stock-trading>true</stock-trading><margin-trading>true</margin-trading><streaming-news>true</streaming-news><option-trading>spread</option-trading><streamer>true</streamer><advanced-margin>true</advanced-margin></authorizations></account><account><account-id>dddddddd</account-id><display-name>xxxxxxira</display-name><cdi>dddddd</cdi><description>xxxxxx IRA</description><associated-account>false</associated-account><company>AMER</company><segment>ADVNCED</segment><unified>true</unified><preferences><express-trading>false</express-trading><option-direct-routing>false</option-direct-routing><stock-direct-routing>false</stock-direct-routing></preferences><authorizations><apex>true</apex><level2>true</level2><stock-trading>true</stock-trading><margin-trading>true</margin-trading><streaming-news>true</streaming-news><option-trading>spread</option-trading><streamer>true</streamer><advanced-margin>true</advanced-margin></authorizations></account></accounts></xml-log-in></amtd>";

// http://api.jquery.com/jQuery.parseXML/
xmlDoc = $.parseXML( xml );
$xml = $( xmlDoc );
$sessionId = $xml.find("session-id");

Open in new window

0
 

Author Comment

by:jackjohnson44
ID: 39176126
jQuery is the best!!!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month17 days, 14 hours left to enroll

830 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