复制代码 代码如下:
'*****************************************************************
'** 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>
您可能感兴趣的文章:
如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!
网友评论