jQuery Ajax calling XML with Xinclude -
so got 3 levels of xml:
app.xml includes 4 categories (xml-files). each category includes number of entries.
the including part right done xinclude.
my script runs ajax function getting first xml, app.xml right now, won't see through xinclude. clarify, alerts 'yes' , 'app' not 'cat'. in console.dir xml see xi:include, not what's in files.
do need parse somehow? xinclude not work, or can include in better way?
script.js
$.ajax({ type: "get", url: "xml/app.xml", datatype: "xml", success: function(xml) { alert('yes'); $(xml).find('app').each(function(){ alert('app'); var test = $(this); console.dirxml(xml); $(this).find('category').each(function(){ alert('cat'); }); }); }, error: function() { alert("the xml file not processed correctly."); } });
app.xml
<?xml version="1.0" encoding="utf-8"?> <app xmlns:xi="http://www.w3.org/2001/xinclude"> <xi:include href="cat1.xml" parse="xml"/> <xi:include href="cat2.xml" parse="xml"/> <xi:include href="cat3.xml" parse="xml"/> <xi:include href="cat4.xml" parse="xml"/> </app>
example of category - xml
<?xml version="1.0" encoding="utf-8"?> <category xmlns:xi="http://www.w3.org/2001/xinclude"> <title>title</title> <introtext>introtext introtext introtext introtext</introtext> <xi:include href="cat1/entry.xml"/> </category>
example of entry - xml
<?xml version="1.0" encoding="utf-8"?> <entry> <rubrik>entry title</rubrik> <text>text text text</text> <bild>pic_name</bild> </entry>
xml text ajax request, need request original file, loop through xi:includes , request each of files , on.
Comments
Post a Comment