Forum Discussion

scsvel's avatar
scsvel
Frequent Contributor
15 years ago

Not able to instantiate DOMParser class

Hi all,

I am creating XML doc via code using XMLWriter class which forms my final XML doc as a string. So finally I want to convert str to actual XML. I tried to use DOMParser as




var domParser = new DOMParser();

var actualXml = domParser.parseFromString(xmlStr, "text/xml");

return actualXml;



But I got error in first line itself. It says like DOMParser undefined. Its not creating instance for DOMParser class as it not identified.



Kindly help me to solve this problem..

1 Reply

  • Hi,



    The DOMParser object is defined by DHTML API that is not available for TestComplete by default. You can try using the following code snippet to accomplish your task:





    // ...

    var DOMDocument = new ActiveXObject("Msxml2.DOMDocument");

    DOMDocument.loadXML(strXML);

    // ...





    For additional information, see the following MSDN Library articles:

    XML DOM Methods

    loadXML Method