I have the following XML file:
<TOOLING>
<TOOLENVIRONMENT>
<TOOL>
<TOOLSNAME>MyABCVersion1</TOOLSNAME>
<TOOLSVERSION>12.34.56</TOOLSVERSION>
</TOOL>
<TOOL>
<TOOLSNAME>MyABCVersion2</TOOLSNAME>
<TOOLSVERSION>23.45.67</TOOLSVERSION>
</TOOL>
<TOOL>
<TOOLSNAME>MyABCVersion3</TOOLSNAME>
<TOOLSVERSION>34.56.78</TOOLSVERSION>
</TOOL>
</TOOLENVIRONMENT>
</TOOLING>
I wanted to get the value of <TOOLS_VERSION>
from XML file by using the <TOOLS_NAME>
. Which means I want to search in XML file for "MyABCVersion1" and retrieve the value "12.34.56". After retrieving I wanted to replace the version name with the new version name which will be provided in the parameters.
I have tried the script like the following by taking the first tag of the file, but in future if the order changes that will not work:
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.Async = False
objXMLDoc.Load("autorun.xml")
WScript.Echo objXMLDoc.Xml
Set ElemList = objXMLDoc.GetElementsByTagName("TOOLSNAME")
plot = ElemList.item(0).Text
WScript.Echo plot
Set ElemList = objXMLDoc.getElementsByTagName("TOOLSNAME")
plot = ElemList.Item(1).Text
WScript.Echo plot