jQuery HTMLCollection, tag stripping

jeeper

New Member
I'm getting some POST data via AJAX as XML, and am trying to load it into a textarea using jQuery, and am running into some problems. The XML looks like this (stripped down, showing only the problem elements):\[code\]<Entry> <Title>A <i>Title</i> with italics.</Title> <Abstract>An abstract, which <i>also</i> may have italics</Abstract></Entry>\[/code\]I've converted this XML into a jQuery object using \[code\]$dom = $(xml)\[/code\], where \[code\]xml\[/code\] is the XML string above. For some reason, jQuery seems to be inconsistent about \[code\].text()\[/code\] versus \[code\].html()\[/code\]. I think the problem has to do with an HTMLCollection (that's what logging the object shows), but I'm not sure.\[code\]$dom.find('Title').text();\[/code\] works as I want it to, turning title into "\[code\]A <i>Title</i> with italics\[/code\]." Doing the same thing on the abstract (\[code\]$dom.find('Abstract').text()\[/code\]) strips the \[code\]<i>\[/code\] tags entirely, resulting in "\[code\]An abstract, which also may have italics\[/code\]".Frustratingly, doing thing with \[code\].html()\[/code\] isn't consistent either!\[code\]$dom.find('Title').html(); #=> 'A <Title>, with italics'$dom.find('Abstract').html() #=> 'An abstract, which <i>also</i> may have...'\[/code\]Any ideas as to what the problem is? The XML is untyped, though I don't think that should make a difference. Thanks!
 
Back
Top