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 ...
随机推荐
- P5468 [NOI2019]回家路线
传送门 看题目一眼斜率优化,然后写半天调不出来 结果错误的 $dfs$ 有 $95$ 分?暴力 $SPFA$ 就 $AC$ 了? 讲讲正解: 显然是斜率优化的式子: 先不考虑 $q_{s_k}$ 的贡 ...
- jQuery easyUI 使用 datagrid 表格
获取后台数据依旧是使用一般处理程序(ashx) ,分页上添加一个函数(pagerFilter(data)) 前端代码: <%@ Page Language="C#" Auto ...
- ActiveMQ的简单使用
项目中使用的介绍 一.运行ActiveMQ 在文件路径下...\apache-activemq-5.13.3\bin\win64 运行activemq.bat 这是系统中的使用,运行后还可以访问相应的 ...
- spring(四):spring中给bean的属性赋值
spring中给bean的属性赋值 xml文件properties标签设置 <bean id="student" class="com.enjoy.study.ca ...
- Ajax —— 服务器端发送JSON数据
重点需要解决的问题:服务器端如何构建JSON数据 思考:JavaBean转JSON数据,集合转JSON数据,普通java对象(String,Number)转JSON数据 一.Gson开源jar包 ...
- 测试微信小程序页面的生命周期
前言:本人是一个初学者,也是第一次写博客,敲键盘的时候还不知道发布后是什么效果,希望内容给其他初学的同学一点帮助,同时加深自己的理解.这篇随笔讲的是Page页面的生命周期,在开发中是基础中的基础,很容 ...
- android&iOS设计分辨率
--- iPhone --- iPhone SE 1136 * 640 2.0875 iPhone 6 1334 * 750 1.778666666666667 iPhone X 2436 * 112 ...
- Introduction to Sound Programming with ALSA
ALSA stands for the Advanced Linux Sound Architecture. It consists of a set of kernel drivers, an ap ...
- rpmcache - 缓存 RPM 打包头部
SYNOPSIS rpmcache [ PACKAGE_NAME ... ] DESCRIPTION rpmcache 遍历文件树,可能通过 FTP 使用远程文件,使用 glob(7) 表达式过滤路径 ...
- hdu 4235 容斥原理模板题
题目大意: 输入样例个数T,每个样例输入三个数a,b,n,求[a,b]之间与n互素的个数 基本思路: 互斥,想想这个:AUBUC=A+B+C-A∩B-A∩C-B∩C+A∩B∩C fac存的是n的素因数 ...