I need to get value of enabled attribute from element <testItem name="Phase0" ...>
Could someone tell me how to do it? I don't know how to do it..
I tried something to help xpath but no result.
The document is loaded but I don't know how to get the attribute value
function getAttrValue()
{
var fileName = "C:\\test.xml";
var doc = Sys.OleObject("Msxml2.DOMDocument.6.0");
doc.load(fileName);
var value = doc.selectSingleNode("/Root/testItems/children/testItem(1)/children/testItem(0)").enabled;
Log.Message(value);
}
the xml code is not complete... it's too long
Thank you
<Root signature="{362A8EE5-675E-43A9-869D-06ECE80B0CB4}" version="14.0">
<testItems key="{18FBEBF5-E1A7-4B44-A78F-4BDB66ECB279}" version="14">
<children>
<testItem name="SETENVIRONMENT" key="{69AEF7E8-30A3-4AA3-B44A-F6F5A0812578}" group="True" parallel="False" enabled="True" testMoniker="" count="1" timeout="0" stopOnError="3" stopOnException="2" description="" tmsData="" testCase="True">
<testParameters />
<children>
<testItem name="Automate" key="{A9BBB245-02DE-4F1D-BEE8-9B3A576E0F04}" group="False" parallel="False" enabled="True" testMoniker="{088295FE-07C1-4A44-83FE-27198978BB3A}AutomateProcessRun" count="1" timeout="0" stopOnError="1" stopOnException="2" description="" tmsData="" testCase="True">
<testParameters />
<environments activeCloud="CBT" />
<children />
</testItem>
</children>
</testItem>
<testItem name="TESTCASES" key="{F27CAF00-67B1-44D6-9D6B-B8A1498AB787}" group="True" parallel="False" enabled="True" testMoniker="" count="1" timeout="0" stopOnError="3" stopOnException="2" description="" tmsData="" testCase="True">
<testParameters />
<children>
<testItem name="Phase0" key="{6D5E60D6-FC79-4ABE-9E4E-95625C081D45}" group="False" parallel="False" enabled="True" testMoniker="KDT\{B024E0F5-9C6E-43B4-BA21-D79A54AF1B61}" count="1" timeout="0" stopOnError="1" stopOnException="2" description="" tmsData="" testCase="True">
<testParameters />
<environments activeCloud="CBT" />
<children />
</testItem>
<testItem name="Phase1" key="{2D49F60C-20B6-4D73-8FC5-FA57B1AA6677}" group="False" parallel="False" enabled="True" testMoniker="KDT\{28D6EBB9-B449-407B-942B-E43C7A6E5E7B}" count="1" timeout="0" stopOnError="1" stopOnException="2" description="" tmsData="" testCase="True">
<testParameters />
<environments activeCloud="CBT" />
<children />
</testItem>
<testItem name="Phase2" key="{EB2033B4-6AB6-409C-8674-90B1CB4C2288}" group="False" parallel="False" enabled="True" testMoniker="KDT\{AB04AC00-EC2F-4CDE-AB21-95327EDC97AE}" count="1" timeout="0" stopOnError="1" stopOnException="2" description="" tmsData="" testCase="True">
<testParameters />
<environments activeCloud="CBT" />
<children />
</testItem>
<testItem name="Phase3" key="{8C5DC219-A594-4790-AF51-CA3FAD21F722}" group="False" parallel="False" enabled="True" testMoniker="KDT\{12B9102E-1E90-4D4F-8B1D-A1AD951BDC85}" count="1" timeout="0" stopOnError="1" stopOnException="2" description="" tmsData="" testCase="True">
<testParameters />
<environments activeCloud="CBT" />
<children />
</testItem>
<testItem name="Phase4" key="{8785B649-B1B5-4A7A-8543-21AD95718EC6}" group="False" parallel="False" enabled="True" testMoniker="KDT\{890BAA92-FF2C-468B-AF0C-80E397C63EE4}" count="1" timeout="0" stopOnError="1" stopOnException="2" description="" tmsData="" testCase="True">
<testParameters />
<environments activeCloud="CBT" />
<children />
</testItem>
</children>
</testItem>
</children>
</testItems>
</Root>
With the caveat that I wasn't able to try it myself, it seems your problem has to do with handling namespaces. One simple way (doesn't always work) is to sidestep them altogether. See what happens if you replace
doc.selectSingleNode("/Root/testItems/children/testItem(1)/children/testItem(0)")
with
doc.selectSingleNode("//*[local-name()="testItem"][@name="Phase0"]/@enabled")