QTP-XML service functions (7) - Add processing instruction

Categories: Source codeXML Data


Parent page: Service Functions – XML (QTP, VBScript)

Description

This particular example demonstrates adding XSL call that contains instructions transforming XML tree to a web-page (HTML).

Built-in QTP support for XML does not provide mapping for XML methods that operate special nodes, like Processing Instructions. It can be done through Microsoft XML DOM object.

Dim objXMLDoc
Dim objNode
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.load("C:\Temp\textdiff.xml")
Set objNode = objXMLDoc.CreateProcessingInstruction("xml-stylesheet", "type=""text/xsl"" href="".\showdiff.xsl""")
objXMLDoc.InsertBefore objNode, objXMLDoc.FirstChild
objXMLDoc.Save("C:\Temp\textdiff.xml")
Set objXMLDoc = Nothing
Set objNode = Nothing

  • Leave a Reply

    * Required
    ** Your Email is never shared

Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported
This work by the author is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported.