Hi,
I have the string like

var test="<NewDataSet>
  <Table1>
    <S_x0020_No>1</S_x0020_No>
    <Defect_x0020_Causes>None</Defect_x0020_Causes>
    <Defect_x0020_Count>2614</Defect_x0020_Count>
    <Percentage>63.22</Percentage>
    <Cumulative_x0020_Percentage>63.22</Cumulative_x0020_Percentage>
  </Table1>
</NewDataSet>"..

So.i would like to convert the string into Xml document..
any idea..

Thanks & Regards,
S.Sajan.

Hi,
I have the string like

var test="<NewDataSet>
  <Table1>
    <S_x0020_No>1</S_x0020_No>
    <Defect_x0020_Causes>None</Defect_x0020_Causes>
    <Defect_x0020_Count>2614</Defect_x0020_Count>
    <Percentage>63.22</Percentage>
    <Cumulative_x0020_Percentage>63.22</Cumulative_x0020_Percentage>
  </Table1>
</NewDataSet>"..

So.i would like to convert the string into Xml document..
any idea..

Thanks & Regards,
S.Sajan.

see:

/**
	 * Parse strings into XML Object
	 * http://onwebdevelopment.blogspot.com/2008/05/converting-xml-to-json.html
	 * @param {String} XML String
	 */
	textToXML: function(strXML) {
		var xmlDoc = null;
		try {
			xmlDoc = (document.all)?new ActiveXObject("Microsoft.XMLDOM"):new DOMParser();
			xmlDoc.async = false;
		} catch(e) {throw new Error("XML Parser could not be instantiated");}
		var out;
		try {
			if(document.all) {
				out = (xmlDoc.loadXML(strXML))?xmlDoc:false;
			} else {  
				out = xmlDoc.parseFromString(strXML, "text/xml");
			}
		} catch(e) { throw new Error("Error parsing XML string"); }
		return out;
	}
This article has been dead for over six months. Start a new discussion instead.