Posted by Albert Gareev on Nov 14, 2009
Parent page: Service Functions – XML (QTP, VBScript) Description Uses .AddChildElementByName method to create a child XML node, then returns reference to the newly created object. If Parent XML node is not defined returns “Nothing”. Public Function CreateChildElementByName(ByRef objXMLParent, ByVal sTagName, ByVal sInnerText) Dim objColl If objXMLParent is Nothing Then Set CreateChildElementByName = Nothing Exit ...
Posted by Albert Gareev on Oct 02, 2009
In the code examples I present I often refer to routine functions. In my framework I have specialized libraries to call from. In my blog I maintain the similar structure. Using built-in QTP-XML Objects and Functions Returns reference of XML Element Returns text value of XML Element Returns reference of XML Attribute Returns text value of [...] ...
Posted by Albert Gareev on Jul 21, 2009
Parent page: Service Functions – XML (QTP, VBScript) Description Retrieves child comment node from comments collection and returns comment text as string. Public Function ChildCommentValue(ByRef objXMLParent, ByVal intNumber) Dim objColl, objComment If objXMLParent is Nothing Then ChildCommentValue = "" Exit Function End If Set objColl = objXMLParent.Comments() If intNumber > objColl.Count Then ChildCommentValue = "" ...
Posted by Albert Gareev on Jul 17, 2009
Parent page: Service Functions – XML (QTP, VBScript) Description Returns scalar value of the XML child attribute specified by a name. Attribute name duplication within the same node is not allowed by XML rules. If there is no attribute with the name specified then “” (empty string) is returned. Public Function ChildAttributeValueByName(ByRef objXMLParent, ByVal sAttrName) Dim objColl, [...] ...
Posted by Albert Gareev on Jul 16, 2009
Parent page: Service Functions – XML (QTP, VBScript) Description Returns XML child attribute (as XMLAttribute object reference) specified by a name. Attribute name duplication within the same node is not allowed by XML rules. If there is no attribute with the name specified then “Nothing” is returned. Public Function ChildAttributeByName(ByRef objXMLParent, ByVal sAttrName) Dim objColl, objAttr If objXMLParent [...] ...
Posted by Albert Gareev on Jul 15, 2009
Parent page: Service Functions – XML (QTP, VBScript) Description Returns scalar value of the XML child node specified by an xml tag name. If there are multiple objects with the same tag, returns value of the first reference. If there are no objects with the tag specified returns “” (empty string). Public Function ChildElementValueByName(ByRef objXMLParent, ByVal [...] ...
Posted by Albert Gareev on Jul 14, 2009
Parent page: Service Functions – XML (QTP, VBScript) Description Returns XML child node (as XMLElement object reference) specified by an xml tag name. If there are multiple objects with the same tag, returns the first reference. If there are no objects with the tag specified returns “Nothing”. Public Function ChildElementByName(ByRef objXMLParent, ByVal sTagName) Dim objColl If objXMLParent [...] ...
Posted by Albert Gareev on May 27, 2009
Original date: N/A The post has been mostly recompiled from the comments. Displaying Text File comparison results in an embedded report. Refer to Text File Compare functions used to see how XML file is generated. Sample requirements to show comparison results stored in XML as a web-page (HTML). 1. Show file stats saved in xml file. [...] ...
Posted by Albert Gareev on May 26, 2009
Original date: 26 Jan 2009, 1:30pm Line by line, and word by word comparison isn’t a big problem. But how conveniently show the results? With WinRunner comparison and reporting has been implemented utilizing WDIFF program. With QTP we can do the same using XML-XSL technology. The function below performs comparison of 2 text files generating [...] ...
Posted by Albert Gareev on Aug 30, 2008
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript) Description Sets text value for the child XML node specified via XPath query. Note: creates a new XML node if nothing was found. Implementation Public Function SetChildElementByAttr(ByRef objXMLParent, ByVal sTagName, ByVal sAttrName, ByVal sValue) Dim objNode sTagName = Trim(sTagName) sAttrName = Trim(sAttrName) sValue = CStr(sValue) [...] ...
Posted by Albert Gareev on Aug 28, 2008
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript) Description Returns text value of a child XML node found via XPath query. Implementation Public Function GetChildElementValueByAttr(ByRef objXMLParent, ByVal sTagName, ByVal sAttrName) Dim objNode sTagName = Trim(sTagName) sAttrName = Trim(sAttrName) If objXMLParent is Nothing Then GetChildElementValueByAttr = "" Exit Function End If Set ...
Posted by Albert Gareev on Aug 27, 2008
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript) Description Returns child XML node via XPath query. Implementation Public Function GetChildElementByAttr(ByRef objXMLParent, ByVal sTagName, ByVal sAttrName) Dim objNode sTagName = Trim(sTagName) sAttrName = Trim(sAttrName) If objXMLParent is Nothing Then Set GetChildElementByAttr = Nothing Exit Function End If Set objNode = ...
Posted by Albert Gareev on Aug 20, 2008
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript) Description Returns text value of a child XML node. Implementation Public Function ChildElementValueByName(ByRef objXMLParent, ByVal sTagName) Dim objNode If objXMLParent is Nothing Then Set ChildElementValueByName = "" Exit Function End If Set objNode = objXMLParent.SelectSingleNode("./"&sTagName) If isNull(objNode) Or (objNode is ...
Posted by Albert Gareev on Aug 19, 2008
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript) Description Returns child node by tag name. Implementation Public Function ChildElementByName(ByRef objXMLParent, ByVal sTagName) Dim objNode If objXMLParent is Nothing Then Set ChildElementByName = Nothing Exit Function End If Set objNode = objXMLParent.SelectSingleNode("./"&sTagName) If isNull(objNode) Or (objNode is Nothing) Then Set ...
Posted by Albert Gareev on Aug 14, 2008
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript) Description Dispatcher type function. Sets child node by name: attribute, text, comment, CData See Test Code section for examples. Implementation Public Function SetXMLElementProperty(ByRef objXMLElement, ByVal sProperty, ByVal intIndex, ByVal sPropertyValue) Dim boolRC Dim sAttrName If objXMLElement is Nothing Then SetXMLElementProperty = False [...] ...
Posted by Albert Gareev on Aug 12, 2008
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript) Description Dispatcher type function. Reads child node by name: attribute, text, comment, CData See Test Code section for examples. Implementation Public Function GetXMLElementProperty(ByRef objXMLElement, ByVal sProperty, ByVal intIndex, ByRef sPropertyValue) Dim sAttrName If objXMLElement is Nothing Then GetXMLElementProperty = False Exit Function End If ...
Posted by Albert Gareev on Aug 06, 2008
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript) Description Set value of a child attribute. Implementation Private Function p_SetXMLElementAttrText(ByRef objXMLElement, ByVal sAttrName, ByVal sValue) Dim boolRC, intRC On Error Resume Next Call objXMLElement.SetAttribute(sAttrName, sValue) intRC = Err.Number On Error GoTo 0 boolRC = intRC <> 0 [...] ...
Posted by Albert Gareev on Aug 05, 2008
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript) Description Returns value of a child attribute. Implementation Private Function p_GetXMLElementAttrText(ByRef objXMLElement, ByVal sAttrName) Dim sResult sResult = objXMLElement.GetAttribute(sAttrName) If isNull(sResult) Then sResult = "" End If p_GetXMLElementAttrText = sResult End Function ...
Posted by Albert Gareev on Jul 25, 2008
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript) Description Iterate to index. Change value for existing CData node. Otherwise create new child nodes till index. Implementation Private Function p_SetXMLElementCDataByIndex(ByRef objXMLElement, ByVal intIndex,ByVal sValue) Dim objXMLDoc, objCDataNode Dim objColl, Iter, IndexIter Set objColl = objXMLElement.ChildNodes IndexIter = -1 For Iter=0 To ...
Posted by Albert Gareev on Jul 24, 2008
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript) Description Remove all existing child CData nodes. Create a new CData node. Implementation Private Function p_SetXMLElementCData(ByRef objXMLElement, ByVal sValue) Dim objXMLDoc, objCDataNode Dim objColl, Iter 'Remove all Set objColl = objXMLElement.ChildNodes Count = objColl.length-1 Iter = 0 Do While Iter [...] ...