html - How can I reference a specific DIV tag INSIDE an XML tag with jquery? -


title says basically.

i using ebay trading api , trying extract text message sent user. api unhelpfully returns ton of html actual user message inside div id userinputtedtext.

i trying data out using jquery - raw xml response in format:

<xmlresponse>     <messages>         <message>             <text>                 "<!doctype html public ...>\n\n\n<html ...>\n\n                     <div id="userinputtedtext">                         ****message user **** 

so have been trying use variation of...

$xml = $.parsexml( xmlresponse ) $xml.find("message").find('text').find('userinputtedtext').html() 

...but nothing seems work.

i should perhaps note can text node , data out in more complicated multi-step process feel there must simpler way.

in fact notice node seems have html wrapped in " , interspersed bunch of \n line breaks seems weird me. can shed light on why is?

you need parse in 2 steps, xml contains html code value. once have parsed xml, html code text, can't use selector find elements in it.

you create jquery object xml document traverse it:

$xml = $($.parsexml(xmlresponse)); 

get text text node , turn html code elements, can find element in it:

var html = $xml.find("message").find('text').text(); $(html).find('#userinputtedtext').html() 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -