/    Sign up×
Community /Pin to ProfileBookmark

How to read an xml file at client side?

I have an xml data stored with an xml file. I want to display xml data by using jquery in web page. Is there any way where we can read it through jquery at client side and display with html format?
Thanks

to post a comment
HTMLJavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMar 18.2019 — [u][XSLT](https://en.wikipedia.org/wiki/XSLT)[/u] jumps to mind.
Copy linkTweet thisAlerts:
@venketprasadMar 21.2019 — Best example with code read xml using jquery is https://www.stoodq.com/article/read-xml-file-using-jquery-3 which will help you. I cant paste full code here so adding the reference for read xml using jquery here. Take look and see if that help you. Let me know if not, I will create sample code for you and send you.

Thanks

Venket
Copy linkTweet thisAlerts:
@siddhi_patelApr 02.2019 — I'm trying to read XML file using jquery and Ajax.

The first step is making sure you have jQuery included on your page.

after that include following code to read xml format file.

$(document).ready(function(){

$.ajax({

type: "GET",

url: "sites.xml",

dataType: "xml",

success: function(xml) {

$(xml).find('site').each(function(){

var id = $(this).attr('id');

var title = $(this).find('title').text();

var url = $(this).find('url').text();

$('

').html(''+title+'').appendTo('#page-wrap');

$(this).find('desc').each(function(){

var brief = $(this).find('brief').text();

var long = $(this).find('long').text();

$('

').html(brief).appendTo('#link_'+id);

$('

').html(long).appendTo('#link_
'+id);

});

});

}

});

});
×

Success!

Help @ndfd2008 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 3.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,

tipper: Anonymous,
tipped: article
amount: 10 SATS,
)...