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

10 Home Security Tips to Help Protect Your Family

Home security is not just about stopping burglars. It is about protecting your family, your…

1 day ago

Benefits of an Integrated Contact Center Solution

Customer Loyalty is one of the most important things for brands today. Everyday companies come…

1 day ago

Australian universities transfer entry pathways explained for international students

If you’re an international student in Australia and thinking about a course transfer or transferring…

2 days ago

Tips to Improve Internet Safety and Security

The internet is a critical part of how we do things today. Anything and everything…

2 days ago

Do Kids Need Basketball Shoes

Yes, your kids need basketball shoes. Many parents think that shoes will not impact performance.…

4 days ago

Top List: Best Apps Every Business Need

If you use the right technology, you can significantly simplify your daily entrepreneurial tasks while…

1 week ago