Friday, 27 January 2012

JavaScript function to get XML object from string

Here's a function that you can use to load an xml object from an xml-formatted string in JavaScript:

function loadXMLFromString(text)
    {
        try //Internet Explorer
        {
            xmlDoc=new ActiveXObject('Microsoft.XMLDOM');
            xmlDoc.async='false';
            xmlDoc.loadXML(text);
        }
        catch(e)
        {
            try //Firefox, Mozilla, Opera, etc.
            {
                parser=new DOMParser();
                xmlDoc=parser.parseFromString(text,'text/xml');
            }
            catch(e) {alert(e.message);}
        }
       
        return xmlDoc;
    }


1 comment:

Manoj Sharma -India Trip Designer said...

Hello Blogger,
Luxury Golden Triangle Tour package is specially designed tour package by Delhi Agra Jaipur Yatra which is connecting three famous heritage cities of India that are nation's capitral Delhi, city of love - Agra and Pink city Jaipur. If you are planning a tour or visiting first time to India for exploring incredible India then these cities are must visit destinations. In luxury Golden Triangle Tour your stay in the best hotels of every city. Hotels include are Oberoi, Leela, Taj, 5 star hotels and other heritage hotelsat best price in the market. Car rental services are also available for exploring the cities of Golden Triangle Tour with Udaipur, Golden Triangle Tour With Ranthambore and other famous cities. If you want to add some more places in your trip, you can Customize Your Tour also. So plan your vacations with Delhi Agra Jaipur Yatra which make your trip more comfortable and hassle free tour.
India Trip Designer
www.indiatripdesigner.com
+91-9837332533