Below is the structure of my xml file:
<configuration>
<appSettings>
<add key="ProductVersion" value="5.5.5"/>
<add key="LogsDirectory" value="e:\\Logs"/>
</appSettings>
<configuration>
I am trying following code to get value of LogsDirectory:
configurationFilePath = "e:\conf.xml"
Set xmlDoc = CreateObject("MSXML2.DomDocument.6.0")
xmlDoc.async = false
Call xmlDoc.load(configurationFilePath)
xpath1 = ".//configuration/appSettings/add[@key='LogsDirectory']/@value"
LogsDirectory = xmlDoc.selectSingleNode(xpath1)
But it is giving error as object required.
Any help highly appreciated.
Thanks
People who not use an error checking skeleton for XML work like this:
also do bungee jumping without ropes.
In your case the .ParseError.Reason
explains why there is no document to search in. At least this spares you the error you'd get when you try to assign the node returned from .selectSingleNode() to LogsDirectory without using Set.