'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. [暑假集训Day3T2]骑士问题

    标准的广搜. 采用队列保存形态,如果不会广搜的可以多看看PJ知识点.由于输入多组数据,每次标记数组要清空,每次队列元素也都要清空. 参考代码如下: #include<iostream> # ...

  2. Dedecms织梦后台登陆验证码不显示几种解决方法

    Dedecms织梦后台登陆验证码不显示几种解决方法,服务器所造成的验证码不显示问题看这里: 方法一:查看服务器的php版本是否与程序版本兼容(织梦程序PHP版本查看方法:打开www.96net.com ...

  3. JS的video获取时长,出现问题汇总

    <video id="my_video_1" controls="controls" style=" width: 700px; height: ...

  4. NodeJs的CommonJS模块规范

    前言 本人记忆力一般,为了让自己理解<深入浅出Node.js-朴灵>一书,会在博客里记录一些关键知识,以后忘了也可以在这里找到,快速回想起来 Node通过require.exports.m ...

  5. C语言获取当前时间

    #include <stdio.h> #include <time.h> void main () { time_t rawtime; struct tm * timeinfo ...

  6. Nginx学习总结(一)

    Nginx是目前比较主流的HTTP反向代理服务器(其企业版提供了基于TCP层的反向代理插件),对于构建大型分布式web应用,具有举足轻重的作用.简单来说,nginx有2个主要的功能:动/静态资源分离. ...

  7. React(2) --super关键字

    参考:http://www.phonegap100.com/thread-4911-1-1.html Es6中的super可以用在类的继承中,super关键字,它指代父类的实例(即父类的this对象) ...

  8. 一、Google开发者工具功能页面截图

    一.利用Chrome开发者工具功能进行网页整页截图的方法. 打开你想截图的网页,然后按下 F12(macOS 是 option + command + i)调出开发者工具, 接着按「Ctrl + Sh ...

  9. jenkins持续集成(三): jenkins配置邮件通知

    完成基于jenkins的持续集成部署后,任务构建执行完成,测试结果需要通知到相关人员.这篇博客,介绍如何在jenkins中配置邮件通知的方法... 一.安装邮件插件 由于Jenkins自带的邮件功能比 ...

  10. mongodb 集合操作 (增删改查)

    1.插入: 使用insert或save方法想目标集合插入一个文档: db.person.insert({"name":"ryan","age" ...