Forum Discussion

AkankshaBist's avatar
AkankshaBist
Occasional Visitor
9 years ago

how to read a .xsl format stylesheet using TestComplete

Hi, 

 

I want to read  a xml, typically a stylesheet in .xsl format. I want to traverse to a particular node which i have  marked in bold. 

 

Can any of you help in the same.

 

<xsl:template match="/">
<xsl:for-each select="c:Akanksha">
<xsl:text>MSH|^~\&amp;|Sanket|</xsl:text><xsl:value-of select="dateConversion:NowDate()" /><xsl:value-of select="dateConversion:NowTime()"/><xsl:value-of select="dateConversion:Offset()"/><xsl:text>||Elena||</xsl:text>
<xsl:text>SFT||||||</xsl:text>
<xsl:text>UAC||</xsl:text>

I want to read the Text in the Red Colour,from the node in blue colour.

 

 

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Consider using the native MSXML library available in Windows.  You can create an instance of a DOMDocument object in TestComplete, load you sheet into it, and then use the various methods available in a native DOMDocument to find your child node.  Create the object like so:

     

    MyDom = Sys.OleObject('MSXML.DOMDocument')
    MyDom.loadXML("C:\MyDir\mystyle.xsl")

    You can then call MyDom.selectSingleNode to find the particular node you're looking for.  If that doesn't work, you can use the "childNodes" property to traverse all the child nodes of the document to find the one you want.  Or... some other method. The point is that you can use the MSXML library to do whatever you would do in any other situation.