preload

ChildAttributeValueByName (QTP, TestComplete, VBScript)

Posted by Albert Gareev on Sep 08, 2012
0
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript) Description Returns text value of node’s child attribute specified by name. Valid arguments: an XML element node (NODE_ELEMENT type), name of the attribute. If XML node is not defined, returns empty string. Uses private function p_GetXMLElementAttrText, defined within the library (see parent page). Implementation Public Function [...] ...

CopyChildElements (QTP, TestComplete, VBScript)

Posted by Albert Gareev on Dec 08, 2011
0
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript) Description Copy all child elements (and attributes, comments, text nodes) from one XML node to another. Implementation Public Function CopyChildElements(ByRef objXMLSrc, ByRef objXMLDest)    Dim objCloneNode      If objXMLSrc is Nothing Then     Set MoveChildElements = objXMLDest     Exit Function    End If    If [...] ...

MoveChildElements (QTP, TestComplete, VBScript)

Posted by Albert Gareev on Dec 06, 2011
0
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript)   Description Move all child elements (and attributes, comments, text nodes) from one XML node to another.  Implementation Public Function MoveChildElements(ByRef objXMLSrc, ByRef objXMLDest)    If objXMLSrc is Nothing Then     Set MoveChildElements = objXMLDest     Exit Function    End If    If objXMLDest is Nothing Then     [...] ...

XMLElementDepth (QTP, TestComplete, VBScript)

Posted by Albert Gareev on Oct 20, 2011
0
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript) Description Locate XML node depth within the hierarchy. Valid argument: an XML element node (NODE_ELEMENT type).  Implementation Public Function XMLElementDepth(ByRef objXMLElement)    Dim intDepth    Dim objXMLNode   If objXMLElement is Nothing Then   XMLElementDepth = -1   Exit Function  End If  'NODE_DOCUMENT(9)  If objXMLElement.NodeType = 9 Then ...

CreateXMLDOMFromString (QTP, TestComplete, VBScript)

Posted by Albert Gareev on Oct 08, 2011
0
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript) Description Create XML DOM object by loading source XML from string. If the string is empty or source XML is invalid returns Nothing. Implementation Public Function CreateXMLDOMFromString(ByVal sXMLSource)   Dim boolRC, intRC   Dim objXMLDoc, objXMLRoot     If Trim(sXMLSource) = "" Then     Set CreateXMLDOMFromString = Nothing     Exit [...] ...

XMLNodeSet2Dictionary (QTP, TestComplete, VBScript)

Posted by Albert Gareev on Jul 20, 2011
0
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript) Service Functions – Dictionary (QTP, TestComplete, VBScript) Description For each occurrence of XML node perform conversion to Dictionary, and store all records in indexed Dictionary object. Implementation Public Function XMLNodeSet2Dictionary(ByRef objXMLNodeSet)   Dim objDictionary   Dim Iter   Set objDictionary = CreateObject("Scripting.Dictionary")  If ...

XMLNode2Dictionary (QTP, TestComplete, VBScript)

Posted by Albert Gareev on Jul 19, 2011
0
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript) Service Functions – Dictionary (QTP, TestComplete, VBScript) Description Create Dictionary object and populate with data (only direct content – text, comments, CData, and attributes) taken from XML node. Naming convention: @attr_name for attributes; #text_index for text nodes; #comment_index for comment nodes; #cdata_index for CData Section nodes. [...] ...

Generating Test Reports: Final Example

Posted by Albert Gareev on Jun 23, 2011
0
Parent page: Generating Test Reports Today I put all examples together.  Here’s our XML record simulating log data of a test session. XML Source <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href=".\LogView4.xsl"?> <log> <area id="A001"> <description>Testing login page, invalid password</description> <step type="#note" ...

XML/XSL Transformation: Using Styles

Posted by Albert Gareev on May 25, 2011
0
Parent page: Generating Test Reports Let’s now take the examples from the previous post, and add more style.  Here’s our XML record simulating log data of a test session. XML Source <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href=".\LogView3.xsl"?> <log> <step type="#note"> <time>21/04/2011 11:45:31 AM</time> ...

XML/XSL Transformation: Using Sub-Templates

Posted by Albert Gareev on Mar 14, 2011
3
Parent page: Generating Test Reports Today I continue with more complex examples using previously demonstrated XSL parsing nodes grouped into sub-templates. Here’s our XML record simulating log data of a test session. XML Source <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href=".\LogView2.xsl"?> <log> <step type="#note"> ...

XML/XSL Transformation: Tree to Table

Posted by Albert Gareev on Mar 04, 2011
1
Parent page: Generating Test Reports Today I present XML Tree to HTML Table transformation example. Here’s our XML record simulating logged test steps. XML Source <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href=".\Tree2Table.xsl"?> <log> <step type="GUI Step"> <description>Pasted data [User1234] in edit box [Username] ...

XML/XSL Transformation: Using Complex Nodes

Posted by Albert Gareev on Mar 03, 2011
0
Parent page: Generating Test Reports Today I present example on dynamically building HTML nodes, with XSL, and from XML data. Here’s our XML record simulating log data of a test session. XML Source <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href=".\LogView1.xsl"?> <log> <step type="GUI Step"> <time>21/04/2011 11:45:31 AM</time> ...

XML/XSL Transformation: Stats Table

Posted by Albert Gareev on Mar 02, 2011
0
Parent page: Generating Test Reports Today I present example of an HTML Table populated with XML data. Here’s our XML record simulating stats data of a test session. XML Source <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href=".\StatsTable.xsl"?> <log> <description>Test login page</description> <reporter>John Doe</reporter> ...

How to update value in XML file (QTP, VBScript)

Posted by Albert Gareev on Dec 30, 2009
0
Parent page: Service Functions – XML (QTP, VBScript)  Answers Description Open XML file – load into memory – locate target nodes – update (replace) values – save XML file (either under a new name or overwrite the original file). Search is performed by tag name (“target_node”). If you pass in a non-string parameter for .SetValue function, convert [...] ...

How to count XML nodes (QTP, VBScript)

Posted by Albert Gareev on Dec 29, 2009
0
Parent page: Service Functions – XML (QTP, VBScript)  Answers 1. How to count all direct children? Set objColl = objParent.ChildElements() intCount = objColl.Count 2. How to count all direct children, specific name tag? Set objColl = objParent.ChildElementsByPath("./wanted") intCount = objColl.Count 3. How to count all descendants? Set objColl = objParent.ChildElementsByPath("descendant::*") intCount = objColl.Count ...

Generating text file from XML template (QTP, VBScript)

Posted by Albert Gareev on Dec 09, 2009
1
Parent page: Service Functions – System (QTP, VBScript) Description If you need to generate text file with values you don’t know ahead you may do it dynamically, by utilizing the function below. Make sure you designed template first. The current logic is oriented to executable text files generation, like Dexterity Macro or OS Shell batch files. Code lines are data-driven, [...] ...

Text File Compare Report example (XML, XSL, HTML)

Posted by Albert Gareev on Dec 03, 2009
1
Root page: Service Functions – XML (QTP, VBScript) Parent page: XSL introduction and references Related post: Text File compare in “WDIFF” style (QTP, VBScript, XML, XSL) – Instructions and XSL script Sample task After line by line (and word by word) text file comparison has been performed, XML log was produced. Review the log, identify and report found issues. [...] ...

XML verification example (XSL, HTML)

Posted by Albert Gareev on Dec 02, 2009
0
Root page: Service Functions – XML (QTP, VBScript) Parent page: XSL introduction and references Sample task Verify “transactions” xml file consisting of 10-1000 records. Only “debit” or “credit” record names are valid. Any other entries must be located and reported. Additionally, identify and report all debit records with debit amount greater than 50.00 Sample XML <?xml version="1.0" ...

XSL introduction and references

Posted by Albert Gareev on Nov 30, 2009
1
Parent page: Service Functions – XML (QTP, VBScript)  What is XSL? The Extensible Stylesheet Language. An XSL script is a set of transformation instructions used by an engine (often, web browser, but could be any other processing program as well) to produce a new document based on XML input document. The original document remains unchanged. The output document [...] ...

XPath introduction and references

Posted by Albert Gareev on Nov 23, 2009
0
Parent page: Service Functions – XML (QTP, VBScript)  Note. Although there could be no “reusable function” that would construct XPath for you, I store current post under “XML Service Functions” category, as it’s closely related to it. XPath is fairly simple to learn and very powerful in use.  You can use free XPath Designer Tool to validate [...] ...
Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported
This work by Albert Gareev is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported.