QTP read or write XML file
'strNodePath = "/soapenv:Envelope/soapenv:Body/getProductsResponse/transaction/queryProducts/queryProduct/keys/keyProducts/keyProduct/attrProduct/attrs/attr"
Function getNodeandValuefromXML(strXmlFilePath, strNodePath) 'passed
Dim xmlDoc, xmlRoot,xmlChildren, xmlChild, childNodeName, childNodeValue
Dim i, strNodeField, strNodeValue
Set xmlDoc = XMLUtil.CreateXML()
xmlDoc.LoadFile strXmlFilePath
Set xmlRoot = xmlDoc.GetRootElement()
Set xmlChildren = xmlDoc.ChildElementsByPath(strNodePath)
intNodeCount = xmlChildren.Count()
For i = 1 To xmlChildren.Count()
Set childNodeName = xmlChildren.Item(i).ChildElementsByPath("name")
strOneField = childNodeName.Item(1).Value
Set childNodeValue = xmlChildren.Item(i).ChildElementsByPath("value")
strOneValue = childNodeValue.Item(1).Value
If strOneValue <>"" Then
strNodeField = strNodeField&"$"&strOneField
strNodeValue = strNodeValue&"$"&strOneValue
End If
Next
strNodeField = mid(strNodeField, 2)
strNodeValue = mid(strNodeValue, 2)
'Combine field and value to a string
strNodeFieldValue = strNodeField&"|"&strNodeValue
Set strRoot = nothing
Set xmlDoc = nothing
getNodeandValuefromXML = strNodeFieldValue
End Function
Function createInputFile(strXmlFilePath, strNodePath, strNodeField, strNodeValue) 'passed
Dim xmlDoc, xmlRoot,xmlChildren, xmlChild, child, updateChild
Dim i, childText
Set xmlDoc = XMLUtil.CreateXML()
xmlDoc.LoadFile strXmlFilePath
Set xmlRoot = xmlDoc.GetRootElement()
'temp = xmlRoot.ElementName
Set xmlChildren = xmlDoc.ChildElementsByPath(strNodePath)
For i = 1 To xmlChildren.Count()
Set child = xmlChildren.Item(i)
childText = child.Value
If strNodeField <> "productId" and strNodeField <> "qty" Then
If trim(childText) = strNodeField Then
Set updateChild = xmlChildren.Item(i).Parent.ChildElementsByPath("value")
updateChild.Item(1).SetValue strNodeValue
Exit For
End If
Else
'Set updateChild = xmlChildren.Item(i).ChildElementsByPath("productId")
child.SetValue strNodeValue
End If
Next
xmlDoc.SaveFile strXmlFilePath
Set strRoot = nothing
Set xmlDoc = nothing
End Function
QTP read or write XML file的更多相关文章
- ILJMALL project过程中遇到Fragment嵌套问题:IllegalArgumentException: Binary XML file line #23: Duplicate id
出现场景:当点击"分类"再返回"首页"时,发生error退出 BUG描述:Caused by: java.lang.IllegalArgumentExcep ...
- Binary XML file line #2: Error inflating
06-27 14:29:27.600: E/AndroidRuntime(6936): FATAL EXCEPTION: main 06-27 14:29:27.600: E/AndroidRunti ...
- Android项目部署时,发生AndroidRuntime:android.view.InflateException: Binary XML file line #168: Error inflating class错误
这个错误也是让我纠结了一天,当时写的项目在安卓虚拟机上运行都很正常,于是当我部署到安卓手机上时,点击登陆按钮跳转到用户主界面的时候直接结束运行返回登陆界面. 当时,我仔细检查了一下自己的代码,并 ...
- ADT开发AndroidManifest.xml file missing错误
一个错误“AndroidManifest.xml file missing”但helloworld目录下有此文件,几番google仍没能解决.想起曾经在网络上看到的一个修复project的办法,抱着死 ...
- SVN :This XML file does not appear to have any style information associated with it.
SVN :This XML file does not appear to have any style information associated with it. The document tr ...
- [vb.net]XML File Parsing in VB.NET
Introduction Parsing XML files has always been time consuming and sometimes tricky. .NET framework p ...
- The AndroidManifest.xml File
manifest (船运的)载货清单 http://www.android-doc.com/guide/topics/manifest/manifest-intro.html Every applic ...
- bug_ _图片_android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
=========== 1 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.zgan.communit ...
- bug_ _ android.view.InflateException: Binary XML file line #2: Error inflating class <unknown
========= 5.0 android异常“android.view.InflateException: Binary XML file line # : Error inflating ...
随机推荐
- 最小公倍数(lcm与gcd)
J - Worker Avin meets a rich customer today. He will earn 1 million dollars if he can solve a hard p ...
- 洛谷 P1589 泥泞路 & 2019青岛市竞赛(贪心)
题目链接 https://www.luogu.org/problemnew/show/P1589 解题思路 用结构体存下每一段泥泞路的左端点和右端点,然后用sort根据左端点排序,采用贪心的思想,从左 ...
- HTTP中ip地址伪造的问题以及解决办法
在真实环境下,php获取客户端ip地址的方法通常有以下几种: (1):通过$_SERVER[ "HTTP_CLIENT_IP" ] (2):通过$_SERVER[ "HT ...
- 【学习总结】Eclipse常用快捷键
相关博文 [JAVA]eclipse-Introduction
- JS书目推荐(私教推荐)
下面几本书是私教推荐的,从入门到提高,从易到难,想找电子版的可以去下面这个网站找找,挺多书籍的 鸠摩搜书https://www.jiumodiary.com/ JavaScript编程精解 (第二版) ...
- MySQL 授权用户 ; 存储过程的DEFINER; 命令分隔符DELIMITER
最近项目中遇到有人使用DEFINER这样的关键字,找了半天没有怎么理解这个意思.以为是限制谁使用这个存储过程,后来测试发现并不是这样. 搜索网上发现很多说法都不正确.看到一篇博客,做了如下介绍,才有所 ...
- [HNOI2015]亚瑟王(概率dp)
题面太长了就不复制了,传送门 一道做了还是很懵逼的题目,感觉以后碰到类似的还是不会,果然HNOI题目很皮. 题解传送 补充一下吧.//感觉他的博客已经写得很好了......Orz 需要的可以两边一起看 ...
- Facebook的利润创下历史新高,不受最近的丑闻影响
外媒:Facebook周三表示,其第一季度收入主要由广告支出,增长49%至120亿美元.净利润同比增长65%,创纪录的49亿美元. 尽管很多用户表示,他们在3月中旬发生的隐私丑闻导致他们删除了Face ...
- Kettle5.4.0 java.lang.OutOfMemoryError
CPU: Intel i3 3.40GHz Memory : 8G Kettle默认配置 将MySQL上的一张29W条数据的表,通过Kettle增量抽取到Vertica数据库中,结果在排序这一步报内存 ...
- vs code 使用技巧整理
快捷键 Ctrl + Shift + F:在文件夹中搜索; Ctrl + Shift + P:命令面板; Ctrl + Shift + T:重新打开 关闭的编辑页面; Ctrl+Shift+PgUp/ ...