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 ... 
随机推荐
- docker pull理解误区
			docker run 命令 如果local image中有对应 镜像+tag 不会从新拉取镜像 docker pull 会进行拉取 先进行镜像更改 [root@master01 ~]# docker ... 
- go 学习之bufio
			bufio模块通过对io模块的封装,提供了数据缓冲功能,能够一定程度减少大块数据读写带来的开销.实际上在bufio各个组件内部都维护了一个缓冲区,数据读写操作都直接通过缓存区进行.当发起一次读写操作时 ... 
- 使用再生龙对ubuntu16.04系统完全备份与还原
			1.制作再生龙U盘启动 1.所需要的软件 1.clonezilla-live-2.5.5-38-amd64.iso(再生龙系统镜像) 2.UltraISO(镜像刻录软件) 3.两个空白U盘(U盘A-用 ... 
- antd desgin vue  报错  Warning: Each record in table should have a unique `key` prop,or set `rowKey` to an unique primary key.
			警告:表的数据源中的每条记录都应该有一个唯一的“key”道具,或者将表的“rowKey”设置为一个唯一的主键, 只需要添加 :rowKey="record => record.id&q ... 
- PLC 控制系统资源
			之前整理的PC高级语言与PLC通讯代码下载链接:三菱:http://blog.sina.com.cn/s/blog_16d7d3ecb0102x6wj.html倍福:http://bbs.elecfa ... 
- bzoj3717 [PA2014]Pakowanie  贪心+状压DP
			题目传送门 https://lydsy.com/JudgeOnline/problem.php?id=3717 题解 这道题大概也就只能算常规的状压 DP 吧,但是这个状态和转移的设计还是不是很好想. ... 
- Exception和Error区别
			原创转载请注明出处:https://www.cnblogs.com/agilestyle/p/11393728.html Exception和Error都是继承了Throwable类,在Java中只有 ... 
- 浅谈SAP CRM和Hybris Commerce里的价格架构折扣
			最近Jerry做了一个和价格折扣相关的原型项目,把学到的知识记录下来,以备将来查阅. 在这个原型项目里,我们用React-Native开发了一个移动应用,用户可以在手机上浏览SAP Hybris Co ... 
- 【HDU6621】K-th Closest Distance【线段树】
			题目大意:给你一堆数,每次询问区间[l,r]中离p第k小的|ai-p| 题解:考虑二分答案,对于每个可能的答案,我们只需要看在区间[l,r]里是否有≥k个比二分的答案还要接近于p的 考虑下标线段树,并 ... 
- python 收集测试日志--格式
			Python的logging模块提供了通用的日志系统,这个模块提供不同的日志级别,并可以采用不同的方式记录日志,比如文件,HTTP GET/POST,SMTP,Socket等,甚至可以自己实现方式记录 ... 
