Hello i want to parse a specific info from xml. In that xml code i want to read ForexBuying of the US DOLLAR. I get msgbox when it\'s US DOLLAR but i want to see its ForexBuyin
Just use XPath (properly, see here). As in:
Dim oFS : Set oFS = CreateObject("Scripting.FileSystemObject")
Dim sFSpec : sFSpec = oFS.GetAbsolutePathName("..\testdata\xml\26144567.xml")
Dim objMSXML : Set objMSXML = CreateObject("Msxml2.DOMDocument")
objMSXML.setProperty "SelectionLanguage", "XPath"
objMSXML.async = False
objMSXML.load sFSpec
If 0 = objMSXML.parseError Then
Dim sXPath : sXPath = "/Tarih_Date/Currency[CurrencyName = ""US DOLLAR""]/ForexBuying"
Dim ndDollar : Set ndDollar = objMSXML.selectSingleNode(sXPath)
If ndDollar Is Nothing Then
WScript.Echo sXPath, "failed"
Else
WScript.Echo "ForexBuying:", ndDollar.text
End If
Else
WScript.Echo objMSXML.parseError.reason
End If
output:
cscript 26144567.vbs
ForexBuying: 2.2829