Deva,
I don't think it's possible to use XQuery syntax and FLWOR expressions directly in TestComplete scripts.
You can try working with XML documents using the Microsoft DOM objects.
Below, is a code snippet that demonstrates this:
function test()
{
var xmlDoc, s;
// Specify your file name
var FileName = "C:\\My Folder\\My Project\\My_File.xml";
// Load xml file
xmlDoc = new ActiveXObject("Msxml2.DOMDocument.4.0");
xmlDoc.load(FileName);
// Check errors
if (xmlDoc.parseError.errorCode != 0)
{
s = "Reason: " + xmlDoc.parseError.reason + "\n" +
"Line: " + xmlDoc.parseError.line + "\n" +
"Text: " + xmlDoc.parseError.srcText;
Log.Error("Failed to open file " + FileName, s);
return;
}
// Specify your XPath expression
var xmlNode = xmlDoc.selectSingleNode("//rootElement/headerElement/@textAttr");
if (xmlNode != null)
Log.Message(xmlNode.text);
else
Log.Message("Not found");
}