views:

60

answers:

1
$.ajax({
type: "GET",
url: "awards.xml",
dataType: "xml",
success: parseXml
});
function parseXml(xml)
{

I see

 $("#xml_test").append($(this).find("award").text());  });

returns all the text from my award nodes

 $("#xml_test").append($(this).find("award").html());  });

my award nodes have some html in them so i was hoping i could display it with .html() but i can see in the documentation that .html() cannot be used with xml.

Is there an alternative or workaround that someone knows of to display the html similar to the asXML() function in PHP.

Thanks

+4  A: 

I think that one is related to your question: http://stackoverflow.com/questions/652159/parsing-xml-with-cdata-with-jquery

Basically use XMLDom, not JQuery for this Task. Then you can put your HTML into a CDATA block and output your award content right away (that's how I understood your problem):

<awards>
    <award>
     <![CDATA[
     <strong>>You won this award</strong>
     ]]>
    </award>
</awards>
Daff