Copy Code code as follows:
'*****************************************************************
' * * Script:getxmlelement.vbs
' * * version:1.0
' * * created:1/8/2009 10:58pm
' * * Author:adriaan Westra
' * * e-mail:
' * * purpose/comments:
' * * Get a element from 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:
Copy Code code as follows:
<?xml version= "1.0"?>
<album>
<title>bloemen& Lt;/title>
<DSC_2710>
<alt>Pioenroos</alt>
<title>Pioenroos</title> Br></dsc_2710>
<DSC_4777>
<alt>DSC_4777</alt>
<title>dsc_4777</title >
</DSC_4777>
<DSC_4787>
<alt>Vingerhoedskruid</alt>
<title>vinge Rhoedskruid</title>
</DSC_4787>
<DSC_4899>
<alt>Lavendel</alt>
<t Itle>lavendel</title>
</DSC_4899>
<DSC_5003>
<alt>Zonnebloem</alt>
<title>zonnebloem</title>
</DSC_5003>
</album>