'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. Assembly language 再读---续

    前面已经写到了第三章的数据类型 的那一部分 接下来是一些关于伪指令和其他杂七杂八的东西 1. 当前地址计数器:   $ 常用于  计算数组以及字符串的长度,如: .data list db ,,,,, ...

  2. 2019牛客暑期多校训练营(第一场) - A - Equivalent Prefixes - 单调栈

    A - Equivalent Prefixes - 单调栈 题意:给定两个n个元素的数组a,b,它们的前p个元素构成的数组是"等价"的,求p的最大值."等价"的 ...

  3. C# lodop 打印控件的使用

    原文:https://www.cnblogs.com/izhiniao/p/4160117.html 官网:http://www.mtsoftware.cn/demo.html 先看效果图 : lod ...

  4. owaspbwa tickets

    owaspbwa tickets 来源  https://sourceforge.net/p/owaspbwa/tickets/ 192 SQL Injection in pic_id paramet ...

  5. swiper插件在ie浏览器无反应,解决办法

    在写pc端页面时,用swiper插件发现在ie中用不了,百度下说是swiper从3以后向手机端发展,所以在pc端无响应.后来了解到,swiper3是专门针对移动端写的.如果想兼容IE8的话,应该引入s ...

  6. JavaScript——实现继承的几种方式

    实现继承的6中方法: 借用构造函数 组合继承 原型式继承 寄生式继承 寄生组合式继承 拷贝继承 1. 借用构造函数 在子类型构造函数的内部调用超类构造函数.通过使用apply()和call()方法在新 ...

  7. ECMAScript严格模式

    ECMAScript 第5个版本 1. 严格模式: 什么是: 比普通js运行机制,要求更严格的模式 为什么: js语言本身具有很多广受诟病的缺陷 何时: 今后所有的js程序,必须运行在严格模式下! 如 ...

  8. docker镜像源设置

    由于docker默认镜像源为国外官方源,下载速度较慢.设置国内镜像源可加速 修改文件 /etc/docker/daemon.json vi /etc/docker/daemon.json 添加以下内容 ...

  9. 265-Keystone II JESD204B 66AK2L06 评估模块 (现行) XEVMK2LX

    Keystone II JESD204B 66AK2L06 评估模块 (现行) XEVMK2LX 一. 板卡概述The XEVMK 2LX is a full-featured evaluation ...

  10. Linux双网卡绑定bond详解

    参考资料: 1.https://blog.csdn.net/shengerjianku/article/details/79221886