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

How Does Shade and Bad Weather Impact Solar Panels?

Solar panels work by converting the solar energy received from the sun into usable electric…

1 day ago

Websites Design Companies: How They Help Businesses Succeed Online

In today’s digital-first economy, your website is often the first impression your business makes. Whether…

3 days ago

Best Social Media Agencies in Dubai – 2025 Guide

Dubai’s digital landscape is highly competitive, making it essential for businesses to work with the…

4 days ago

Tips on Hiring Plumbing Contractors Company

Are you planning to hire plumbers for repairing water lines, checking the level of your…

5 days ago

Common Household Plumbing Problems That Sydney Residents Endure

Despite being one of the most expensive real estate markets in the world, Australians still…

5 days ago

The Best Online Grammar Checkers

Below are the tools that actually help instead of confusing you with long explanations or…

1 week ago