getxmlelement.vbs

Get information from an XML file.
This script demonstrates how to get information from an xml file with the use of MSXML. The example xml file is used for the photo album on the site. This script will return the title for a specific picture.

‘*****************************************************************
‘** 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 :



Bloemen

Pioenroos
Pioenroos


DSC_4777
DSC_4777


Vingerhoedskruid
Vingerhoedskruid


Lavendel
Lavendel


Zonnebloem
Zonnebloem

Geef een reactie

Het e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *