Consider a XML document books.xml. The below code will parse this XML document into an XML document object or DOM.
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","books.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
Now, Consider the case when you have an XML String on a client side and you want to convert it into a DOM object. This also can be achieved using javascript by using the below code snippet.
txt="<Customer>";
txt=txt+"<title>JavaGenious</title>";
txt=txt+"<author>www.javagenious.com</author>";
txt=txt+"<year>2007</year>";
txt=txt+"</Customer>";
parser=new DOMParser();
xmlDoc=parser.parseFromString(txt,"text/xml");