Search code examples
jqueryhtmlxmlparsingmeta-tags

Parsing an xml document in jquery and retrieving HTML data


I'm parsing an xml document using jquery successfully, but I can't seem to maintain any of my HTML tags when using: $(this).find("p").text()

My xml looks something like this:

<block>
  <p><b>Speech:</b> Some text</p>
  <a>http://www.ur.com/</a>
</block>

I understand that .text() strips out all html tags, but how do I retrieve the data between my <p> tags, so that I end up with "<b>Speech:</b> Some text"?


Solution

  • I think I found the answer, well at least it works for this situation, maybe because my xml tags are reflections of my html content. The problem was in the ajax dataType, I had it set to "xml", and as soon as I set it to "html" I was able to use .html() Method after my .find() Thanks to everyone who contributed.