'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的更多相关文章

  1. ILJMALL project过程中遇到Fragment嵌套问题:IllegalArgumentException: Binary XML file line #23: Duplicate id

    出现场景:当点击"分类"再返回"首页"时,发生error退出   BUG描述:Caused by: java.lang.IllegalArgumentExcep ...

  2. 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 ...

  3. Android项目部署时,发生AndroidRuntime:android.view.InflateException: Binary XML file line #168: Error inflating class错误

    这个错误也是让我纠结了一天,当时写的项目在安卓虚拟机上运行都很正常,于是当我部署到安卓手机上时,点击登陆按钮跳转到用户主界面的时候直接结束运行返回登陆界面.    当时,我仔细检查了一下自己的代码,并 ...

  4. ADT开发AndroidManifest.xml file missing错误

    一个错误“AndroidManifest.xml file missing”但helloworld目录下有此文件,几番google仍没能解决.想起曾经在网络上看到的一个修复project的办法,抱着死 ...

  5. 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 ...

  6. [vb.net]XML File Parsing in VB.NET

    Introduction Parsing XML files has always been time consuming and sometimes tricky. .NET framework p ...

  7. The AndroidManifest.xml File

    manifest (船运的)载货清单 http://www.android-doc.com/guide/topics/manifest/manifest-intro.html Every applic ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. ac自动机(tree+kmp模板)

    Keywords Search Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others ...

  2. js操作对象属性用点和用中括号有什么不同

    书读百遍其义自见 学习<JavaScript设计模式>一书时,学习工厂模式这一章节,发现了对象后使用中括号的情况,如下: var Factory=function(type,content ...

  3. jar 启动脚本

    前段时间用springboot做项目后,每次重新发布都好麻烦, 所以写了个脚本来配合jenkins 发布: #!/bin/bash APP_NAME=application.jar function ...

  4. Python Web开发:Django+BootStrap实现简单的博客项目

    创建blog的项目结构 关于如何创建一个Django项目,请查看[Python Web开发:使用Django框架创建HolleWorld项目] 创建blog的数据模型 创建一个文章类 所有开发都是数据 ...

  5. Spring-DI控制反转和IOC依赖注入

    Spring-DI控制反转和IOC依赖注入 DI控制反转实例 IDEAJ自动导入Spring框架 创建UserDao.java接口 public interface UserDao { public ...

  6. BZOJ 4034 树链剖分

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=4034 题意:中文题面 思路:树链剖分入门题. 剖分后就是一个简单的区间更新和区间求和问题. ...

  7. CenterOS 7安装Nginx

    1.wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm下载对 ...

  8. MinMax 容斥 学习笔记

    基本形式 \[ \max(S) = \sum_{T\subseteq S, T \neq \varnothing} (-1)^{|T|-1}\min(T) \] 证明 不提供数学证明. 简要讲一下抽象 ...

  9. uwsgi部署django项目

    一.更新系统软件包 yum update -y 二.安装软件管理包及依赖 yum -y groupinstall "Development tools" yum install o ...

  10. Makefile中的$@ $< $^的意义

    $@  目标文件 $<   第一个依赖文件 $^  所有的依赖文件 $? 比目标还要新的依赖文件列表 $%  仅当目标是函数库文件中,表示规则中的目标成员名 $+  所有依赖目标的集合,与$^类 ...