?
Solved

jquery of javascript parse xml

Posted on 2013-05-17
2
Medium Priority
?
566 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 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

Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

Question has a verified solution.

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

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
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)
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

752 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