Solved

jquery of javascript parse xml

Posted on 2013-05-17
2
555 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
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 …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

688 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