Parsing complex XML with jQuery

JenetteB1994

New Member
I'm trying to parse the following XML with the following jQuery. Nothing is displayed on the page. I know it's getting the file. I've looked online and though there are many examples of parsing xml with jquery none of them looked like this formatting.XML:\[code\]<?xml version="1.0" encoding="utf-8"?><wcm:root xmlns:wcm="http://www.stellant.com/wcm-data/ns/8.0.0" version="8.0.0.0"> <wcm:element name="title"></wcm:element> <wcm:element name="wide_image"><img src=http://stackoverflow.com/questions/11209139/'[!--$wcmUrl&x28;'resource','CMS3_130980'&x29;--]'/></wcm:element> <wcm:element name="image"><img src="http://stackoverflow.com/questions/11209139/[!--$wcmUrl('resource','CMS3_132821')--]"/></wcm:element> <wcm:element name="body"><p> Paragraph of text goes here.<br /><br /> Paragraph of text goes here.<br /><br /> Paragraph of text goes here.<br /><br /> Paragraph of text goes here.<br /><br /> Paragraph of text goes here.</p></wcm:element></wcm:root>\[/code\]HTML & jQuery:\[code\]<html><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script><script type="text/javascript">$(document).ready(function () { $.ajax({ type: "GET", url: "link_to_my_file.xml", dataType: "xml", success: parseXml });});function parseXml(xml){ $(xml).find("wcm\\3a root").each(function(){ alert("Test"); $("#output").append($(this).attr("title") + "<br />"); $("#output").append($(this).attr("wide_image") + "<br />"); $("#output").append($(this).attr("image") + "<br />"); $("#output").append($(this).attr("body") + "<br />"); }); };</script><div id="output"></div></html>\[/code\]
 
Back
Top