<div class="news"><a href="subsides/news.php">
<p id="p1">Text comes here</p>
<p id="p2">Another text comes here</p>
<p id="p3">...</p>
<p id="p4">...</p></a></div>
As above i have a div with four p-tags and i want to load text from an xml! I tried around, searched here, but found nth that suits my case! How could the xml-file and the javascript look like??
<?xml version="1.0" encoding="utf-8"?>
<news name = "one">
<p id="p1">bla bla bla</p>
<p id="p2">bla bla bla</p>`
</news>
And the javascript:
$.ajax({
url: "news.xml",
type: "GET",
dataType: "xml",
success: function (xml) {
var xmlDoc = $.parseXML(xml),
$xml = $(xmlDoc);
$xml.find('news[name="one"]').each(function () {
$(".news").append($(this).text());
});
}
});