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

Complete Medical Guide to Blood Sugar Testing and Glucose Control

Introduction When patients bring me their lab reports, the confusion is almost always the same.…

2 days ago

6 Tips to Strategically Remodel Your Home

Are you excited about remodeling your house after a long time? Perhaps if you're planning…

2 days ago

Driving Finding Balance on and off the Mat: How Calm Awareness Supports Everyday

The practice of yoga teaches us to be present, patient and mindful of our decisions.…

3 days ago

7 Things to carry with you on hill station

As we are once again allowed to go outside, nearly everyone is planning to go…

6 days ago

Professional Cleaner Hire Guide for Your Business

How do you find a cleaning company that will take excellent care of your business…

1 week ago

5 Inspirational Gift Ideas That Could Help You Out Last Minute

Finding a gift is always a big task. What is more harder when you are…

2 weeks ago