当前位置: 移动技术网 > IT编程>脚本编程>VBScript > 从XML文件中获取信息的vbs代码

从XML文件中获取信息的vbs代码

2017年12月08日  | 移动技术网IT编程  | 我要评论
复制代码 代码如下: '***************************************************************** '** scri
复制代码 代码如下:

'*****************************************************************
'** script: getxmlelement.vbs
'** version: 1.0
'** created: 1/8/2009 10:58pm
'** author: adriaan westra
'** e-mail:
'** purpose / comments:
'** get an element from a xml file
'**
'**
'** changelog :
'** 1/8/2009 10:58pm : initial version
'**
'*****************************************************************
dim objxml ' object to hold the xml document
dim objnnode ' xml node object

'*****************************************************************
'** create the xml object
set objxml = createobject("msxml2.domdocument.6.0")

'*****************************************************************
'** load the xml from file
objxml.load("album.xml")
'*****************************************************************
'** set language for finding information to xpath
objxml.setproperty "selectionlanguage", "xpath"
'*****************************************************************
'** get a reference to the node
set objnode = objxml.selectsinglenode("/album/dsc_2710/title")
'*****************************************************************
'** output the requested text
wscript.echo "title : " & objnode.text

the sample xml file used by the script :
复制代码 代码如下:

<?xml version="1.0"?>
<album>
<title>bloemen</title>
<dsc_2710>
<alt>pioenroos</alt>
<title>pioenroos</title>
</dsc_2710>
<dsc_4777>
<alt>dsc_4777</alt>
<title>dsc_4777</title>
</dsc_4777>
<dsc_4787>
<alt>vingerhoedskruid</alt>
<title>vingerhoedskruid</title>
</dsc_4787>
<dsc_4899>
<alt>lavendel</alt>
<title>lavendel</title>
</dsc_4899>
<dsc_5003>
<alt>zonnebloem</alt>
<title>zonnebloem</title>
</dsc_5003>
</album>

如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网