DO YOU NEED A CONTENT WRITER FOR YOUR BUSINESS?

Your One-Stop Solution for All Content Needs! Click here for more!
Categories: jQuery

jQuery Makes Parsing XML Easy

Share

jQuery.parseXML uses native parsing function of the browser to create a valid XML document.

After that this document can then be passed to jQuery for creating a typical jQuery object which can be traversed and manipulated then.

This is a easy technique of parsing JSON with jQuery and thought i’d pick this up and show you how to parse XML. It is available from jQuery 1.5 version.

Here is the XML code for the purpose of the demo.

var xml = "<note><heading>Sample Heading</heading><body>Hi! Is this the body you are looking for?</body></note>";
xmlDoc = $.parseXML( xml );
$xml = $( xmlDoc );
$body = $xml.find( "body" );
console.log($body.text());

You will get the result: Hi! Is this the body you are looking for?

Get more details from jQuery reference.

Namaste UI

For any types of queries, you can contact us on info[at]namasteui.com.

Recent Posts

MySQL JSON Operations | Advantages and Limitations

JSON's popularity has risen steadily since its inception nearly 15 years ago. JSON is used…

2 days ago

4 Easy to Steps to Develop a SaaS Accounting Software

Every business needs financial foresight to make one of its pillars stronger and to make…

2 days ago

How to Track Results When You Promote Services for Followers & Likes

One of the trends in social media marketing is the promotion of services that foster…

3 days ago

How to Use Micro-Influencers for More Authentic Promotion

The second article illustrates how micro-influencers can be applied more effectively in the promotion process.…

3 days ago

Why Cheap Follower Packages Can Backfire for Brands

In the end, in the social media battle for eyeballs, the sheer number of followers…

3 days ago

How to Find Influencers Who Actually Boost Engagement

This is not about just the word-of-mouth buzz on influencer marketing. It ranks in the…

3 days ago