Forum Discussion

llaskin's avatar
llaskin
Occasional Contributor
16 years ago

Working With XML Files From Scripts

I've followed the instructions to the letter on the help page titled



"Working With XML Files From Scripts"



I've created the exact same data.xml and placed it in my root directory.  I've cut and paste the exact function into my project.



However, on the line "Doc = Sys.OleObject("Msxml2.DOMDocument.4.0");  I get an error  "An exception occurred in the "filename" unit at line 132: Invalid Class string: cannot obtain ClassID"



Can you help clarify the issue?

5 Replies

  • Hi Leo,



    MSMXL 4 is not installed or is corrupted on your machine. You can download it from here.
  • I have to dispaly the xml data into html.  In xml file node elements are having same name but attribute name is different. could you please tell me how to display xml data into html.  Actually I am trying to covert .mds file into xml then I have to display the xml file into html file. 



     <?xml version="1.0" encoding="UTF-8" standalone="no" ?>

      <!DOCTYPE Nodes (View Source for full doctype...)>



    - <Nodes version="1">





    - <Node name="root">





    - <Node name="folders">





      <Node name="folders" />


      </Node>





    - <Node name="logs">





    - <Node name="log0">





      <Prp name="caption" type="S" value="" />




      <Prp name="datetime" type="D" value="40555.8125774653" />




      <Prp name="description" type="S" value="" />




      <Prp name="index" type="I" value="0" />




      <Prp name="key" type="S" value="{D57398B2-88CC-4117-A845-A7EC05154B10}" />




      <Prp name="nameofroot" type="S" value="ProjectTestItem4" />




      <Prp name="relpath" type="S" value="1_12_2011_7_30 PM_06_584\Description.tcLog" />




      <Prp name="status" type="I" value="2" />


      </Node>





    - <Node name="log1">





      <Prp name="caption" type="S" value="" />




      <Prp name="datetime" type="D" value="40555.8170275579" />




      <Prp name="description" type="S" value="" />




      <Prp name="index" type="I" value="1" />




      <Prp name="key" type="S" value="{AF25C22C-3D93-4589-AB5B-F1228DBB5F2B}" />




      <Prp name="nameofroot" type="S" value="Script Test Log [ExportLog\ExportLog]" />




      <Prp name="relpath" type="S" value="1_12_2011_7_36 PM_31_181\Description.tcLog" />




      <Prp name="status" type="I" value="0" />


      </Node>





    + <Node name="log2">





      <Prp name="caption" type="S" value="" />




      <Prp name="datetime" type="D" value="40555.8415466551" />




      <Prp name="description" type="S" value="" />




      <Prp name="index" type="I" value="2" />




      <Prp name="key" type="S" value="{A4AF26BE-E4CB-41B6-8218-501A30E3F69F}" />




      <Prp name="nameofroot" type="S" value="Script Test Log [ExportLog\ExportLog]" />




      <Prp name="relpath" type="S" value="1_12_2011_8_11 PM_49_631\Description.tcLog" />




      <Prp name="status" type="I" value="0" />


      </Node>





    - <Node name="log3">





      <Prp name="caption" type="S" value="" />




      <Prp name="datetime" type="D" value="40557.7648095718" />




      <Prp name="description" type="S" value="" />




      <Prp name="index" type="I" value="3" />




      <Prp name="key" type="S" value="{FFF070E5-7D5A-45F7-AAC5-6F0B144932CF}" />




      <Prp name="nameofroot" type="S" value="Script Test Log [ExportLog\ExportLog]" />




      <Prp name="relpath" type="S" value="1_14_2011_6_21 PM_19_547\Description.tcLog" />




      <Prp name="status" type="I" value="0" />


      </Node>





    - <Node name="log4">





      <Prp name="caption" type="S" value="" />




      <Prp name="datetime" type="D" value="40557.76689" />




      <Prp name="description" type="S" value="" />




      <Prp name="index" type="I" value="4" />




      <Prp name="key" type="S" value="{1786F7E1-D897-481B-8CA2-1502CAA3DA9A}" />




      <Prp name="nameofroot" type="S" value="Script Test Log [ExportLog\ExportLog]" />




      <Prp name="relpath" type="S" value="1_14_2011_6_24 PM_19_280\Description.tcLog" />




      <Prp name="status" type="I" value="0" />


      </Node>



      </Node>





      <Prp name="signature" type="S" value="{681DCC69-A39F-4C4D-8E7D-B2D9362FAF4F}" />




      <Prp name="version" type="S" value="7.0" />


      </Node>



      </Nodes>



  • Hi,



    You can find an example of parsing an XML file in the "Working With XML Files From Scripts" help topic. Just parse your file, retrieve the information you need from it and save this information in any custom format you want.
  • Hi 



        I am in the phase of creating test summary report by convert project log.mds file into xml file and using XSLT try to display in HTML.  I have faced some problem to count the total node and I am unable to display as link for relpath.  below i have mention xml file and xslt.  suggest me the best solution for this problem

    XML File


    <?xml version="1.0" encoding="UTF-8" standalone="no"?>

    <?xml-stylesheet type="text/xsl" href="MiserQA.mds.tcLogs.xsl"?>

    <!DOCTYPE Nodes [


    <!ENTITY % NameValue "CDATA">

    <!ENTITY % PropType "(I|S|D|L|H|B)">

    <!ENTITY % VersionValue "CDATA">


    <!ELEMENT Prp (#PCDATA)>

    <!ELEMENT Node (Node|Prp)*>

    <!ELEMENT Nodes (Node)+>


    <!ATTLIST Nodes version CDATA "1">


    <!ATTLIST Node name CDATA #REQUIRED>


    <!ATTLIST Prp name CDATA #REQUIRED>

    <!ATTLIST Prp type CDATA #REQUIRED>

    <!ATTLIST Prp value CDATA #REQUIRED>

    ]>

    <Nodes version="1">

     <Node name="root">

      <Node name="folders">

       <Node name="folders"/>

      </Node>

      <Node name="logs">

       <Node name="log0">

        <Prp name="caption" type="S" value=""/>

        <Prp name="datetime" type="D" value="40581.0958974537"/>

        <Prp name="description" type="S" value=""/>

        <Prp name="index" type="I" value="0"/>

        <Prp name="key" type="S" value="{4B0C037F-5A1F-4128-AF65-066A4C0CE028}"/>

        <Prp name="nameofroot" type="S" value="Script Test Log [ACHReturn0113\Main]"/>

        <Prp name="relpath" type="S" value="2_7_2011_2_18 AM_05_540\Description.tcLog"/>

        <Prp name="status" type="I" value="2"/>

       </Node>

       <Node name="log1">

        <Prp name="caption" type="S" value=""/>

        <Prp name="datetime" type="D" value="40581.0977670718"/>

        <Prp name="description" type="S" value=""/>

        <Prp name="index" type="I" value="1"/>

        <Prp name="key" type="S" value="{C8D703AA-06F1-46D5-86C4-540DBEC12A4D}"/>

        <Prp name="nameofroot" type="S" value="Script Test Log [ACHReturn0113\Main]"/>

        <Prp name="relpath" type="S" value="2_7_2011_2_20 AM_47_75\Description.tcLog"/>

        <Prp name="status" type="I" value="0"/>

       </Node>

       <Node name="log2">

        <Prp name="caption" type="S" value=""/>

        <Prp name="datetime" type="D" value="40581.0981584375"/>

        <Prp name="description" type="S" value=""/>

        <Prp name="index" type="I" value="2"/>

        <Prp name="key" type="S" value="{3653F207-DA61-4400-A505-1F72C4C736DD}"/>

        <Prp name="nameofroot" type="S" value="Script Test Log [genericfunctest\genericfunctest]"/>

        <Prp name="relpath" type="S" value="2_7_2011_2_21 AM_20_889\Description.tcLog"/>

        <Prp name="status" type="I" value="0"/>

       </Node>

       <Node name="log3">

        <Prp name="caption" type="S" value=""/>

        <Prp name="datetime" type="D" value="40581.0987017014"/>

        <Prp name="description" type="S" value=""/>

        <Prp name="index" type="I" value="3"/>

        <Prp name="key" type="S" value="{5E75C096-F0AD-44EA-8196-F7960E3341AD}"/>

        <Prp name="nameofroot" type="S" value="Script Test Log [finddynamicobject\finddynamicobject]"/>

        <Prp name="relpath" type="S" value="2_7_2011_2_22 AM_07_827\Description.tcLog"/>

        <Prp name="status" type="I" value="0"/>

       </Node>

      </Node>

      <Prp name="signature" type="S" value="{681DCC69-A39F-4C4D-8E7D-B2D9362FAF4F}"/>

      <Prp name="version" type="S" value="7.0"/>

     </Node>

    </Nodes>



    XSLT file


    <?xml version="1.0" encoding="ISO-8859-1"?>


    <xsl:stylesheet version="1.0"

    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


    <xsl:template match="/">

      <html>

      <body>

      <h2>Miser QA TestComplete Test Results</h2>

    <pre>

            Test Script count  = total count of nodes

            Test script pased =  toatal count when status =0

            Test Script Failed = total count when  status=1

            Test script with warnnings = Total count when status =2

      <table border="1">

        <tr bgcolor="#9acd32">

          <th>Index</th>

          <th>Script</th>

          <th>Status</th>

          <th>Realtive Path</th>

         

        </tr>

        <xsl:for-each select="Nodes/Node/Node/Node">

        <xsl:sort select="Prp[@name='index']/@value"/>

         <tr>

           <td><xsl:value-of select="Prp[@name='index']/@value"/></td>

           <td><xsl:value-of select="Prp[@name='nameofroot']/@value"/></td>

            <xsl:if test="status &et; 0">


           <td><xsl:value-of select="Prp[@name='status']/@value"/></td>



           <td><xsl:value-of select="Prp[@name='relpath']/@value"/></td>

         </tr>

        </xsl:for-each>

      </table>

      </body>

      </html>

    </xsl:template>


    </xsl:stylesheet>