'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. python中单下划线(_)和双下划线(__)的特殊用法

    单下划线开头(_) 在模块中使用单下划线开头 模块中使用单下划线(_)开头定义函数.全局变量和类不能被模块外部以: from module import *形式导入. 但可以用:from module ...

  2. hadoop1.2.1配置与运行子串统计程序

    一.虚拟机版本 VirtualBox-4.3.30 二.操作系统 CentOS-6.7-x86_64-bin-DVD1.iso 下载地址1:http://www.centoscn.com/Centos ...

  3. go语言从例子开始之Example35.原子计数器

    Go 中最主要的状态管理方式是通过通道间的沟通来完成的,我们在工作池的例子中碰到过,但是还是有一些其他的方法来管理状态的.这里我们将看看如何使用 sync/atomic包在多个 Go 协程中进行 原子 ...

  4. Word里的红色、绿色和蓝色波浪线

    有时候我们写完文章会发现,有的地方有红色波浪线,有的地方有绿色/蓝色二重线,那么这两种线各代表什么意思呢?其实红色波浪线代表此处存在拼写错误,绿色/蓝色波浪线代表此处可能有语法错误.如果你不希望Wor ...

  5. java ArrayList的几种方法使用

    package java06; import java.util.ArrayList; /* ArrayList的常用的几个方法: public boolean add(E e) : 向集合汇总添加元 ...

  6. 并行流水线--求 (B+C)*B/2

    public class Msg { public double i; public double j; public String orgStr = null; } import java.util ...

  7. Linux批量新建文件夹(大括号表达式的应用)

    如果想要批量新建文件夹来存放照片,按照年份和月份,格式为YYYY-MM.可以使用下面命令批量新建: mkdir {2007..2009}-{01..12} 结果如下: 2007-01 2007-07 ...

  8. hdu 1695: GCD 【莫比乌斯反演】

    题目链接 这题求[1,n],[1,m]gcd为k的对数.而且没有顺序. 设F(n)为公约数为n的组数个数 f(n)为最大公约数为n的组数个数 然后在纸上手动验一下F(n)和f(n)的关系,直接套公式就 ...

  9. C# json对象中包含数组对象时,如何存入数据库

    前端创建的的对象例如: C#端这样将数组提取出来存入

  10. React笔记02——React中的组件

    一个网页可以被拆分成若干小部分,每个部分都可以称为组件,即组件是网页中的一部分.组件中还可以有多个组件. 上一节中的App.js就是一个组件(继承了React.Component类的类). 一个组件的 ...