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 ...
随机推荐
- 【接口工具】接口抓包工具之Fiddler
一.Fiddler的基本功能介绍 Fiddler的官方网站: https://www.telerik.com/purchase/fiddler Fiddler是最强大最好用的Web调试工具之一,它能记 ...
- k3 cloud库存管理中的直接调拨单权限分配出现问题
k3 cloud中给直接调拨单分配了对应的权限,但是客户端无法查看到对应的单据 解决办法: 是应为没有发布到对应的客户端和浏览器端,打开bos,找到对应的单据并点击发布,找到对应的目录,如图所示: 把 ...
- js中Date的构造函数解读
javascript中的内置对象是我们经常会用到的,那么今天我们就来说说Date的四种构造方法吧 一.new Date() 这是我们最常使用也最熟悉不过的Date对象的构造方法了,通过无参数的构造函数 ...
- 获取input输入值
- CSS-06 外部JS,CSS文件的寻址问题
如果js.css外部文件有使用到相对路径,其相对路径的基准是不一样的 当一个index.html中引入外部的JS和CSS文件时: 在index.css文件中,相对路径的写法是以css文件相对于img图 ...
- redis还要做
RedisTemplate对各种数据类型的操作记录. Redis深度历险:核心原理和应用实践 https://www.cnblogs.com/kismetv/p/8654978.html
- 如何改变string中的字符值?
string本身是不可变的,因此要改变string中字符,需要如下操作: str := “hello world” s := []byte(str) s[] = ‘o’ str = string(s) ...
- ubuntu tar.gz 包 php7.2 安装
一 官网: https://www.php.net/downloads.php https://blog.izgq.net/archives/910/ https://www.jianshu.com/ ...
- SERVLET API中转发与重定向的区别?
SERVLET API中转发与重定向的区别? 1.转发(forward方法) 转发仅是容器中控制权的转向,在客户端浏览器地址栏中不会显示出转向后的地址. 转发是服务器请求资源,服务器直接访问目标地址的 ...
- 【leetcode】436. Find Right Interval
题目如下: 解题思路:题目要求的是对于任意一个区间i,要找出一个区间j,使得j的起点最接近i的终点.既然这样,我们可以把所有区间的终点组成一个列表,并按大小排序,使用二分查找就可以快速找到j区间.注意 ...