Sowmya Sowmya - 3 months ago 30
jQuery Question

Load xml file content into div using jquery

How to load the xml file content to a div.

Here is my HTML in which I need to load XML content

<div class="editorial" id="news-container">

XML Data

<category name = "My t" id = "1">
<channel name="res" id= "1" type="ecommerce">
<item id="1">
<title>Memory Card MSMT2G</title>
<item id="2">
<title>Apple iPad </title>

And xml file name is

I tried several ways but it didn't work :(

I tried the below method but didn't work.

$('something.xml').find('name').each(function() {
$("#news-container").append($(this).text() + "<br />");


Try this:

// Load the xml file using ajax 
    type: "GET",
    url: "something.xml",
    dataType: "xml",
    success: function (xml) {

        // Parse the xml file and get data
        var xmlDoc = $.parseXML(xml),
            $xml = $(xmlDoc);
        $xml.find('category[name="My t"] logo').each(function () {
            $("#news-container").append($(this).text() + "<br />");

Reference: 1. jQuery.ajax() 2. parseXML()