复制代码 代码如下:
'*****************************************************************
'** 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>
'*****************************************************************
'** 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>
标签:
XML,获取信息
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
内蒙古资源网 Copyright www.nmgbbs.com
暂无“从XML文件中获取信息的vbs代码”评论...