Forum Discussion
Julia_K
Alumni
14 years agoHello Ashok,
To access a particular node whose value you want to obtain, you can use the XPath expression just like Lorenzo suggested.
You can find the detailed information on the XPath expression syntax in MSDN library: http://msdn.microsoft.com/en-us/library/ms256471.aspx and http://msdn.microsoft.com/en-us/library/ms256086.aspx.
For example, to obtain the node with the data_txtBankNumber value, you can use the //TestData/Data[Name='data_txtBankNumber']/Name or //TestData/Data[1]/Name XPath expression.
The following sample script obtains the Name and Value nodes and posts their values to the test log:
function TestWithXPath()
{
var Doc, s, Nodes, Node;
Doc = Sys["OleObject"]("Msxml2.DOMDocument.4.0");
Doc["async"] = false;
Doc["load"]("C:\\Data.xml");
// Use the XPath expression to obtain the needed node
NameNode = Doc["selectSingleNode"]("//TestData/Data[Name='data_txtBankNumber']/Name");
ValueNode = Doc["selectSingleNode"]("//TestData/Data[Name='data_txtBankNumber']/Value");
if (NameNode != null)
Log["Message"](NameNode["text"]);
if (ValueNode != null)
Log["Message"](ValueNode["text"]);
}
Please let us know whether this information helps.
Thank you.