PDA

View Full Version : //element[@attribute] in vbscript


Albert
08-23-2006, 04:56 PM
I'm trying to write a script that executes an xpath query that contains square brackets but I keep getting errors. The script works when tested in a .vbs file.

I think it has something to do with the [] brackets. I tried using the literal syntax using double brackets but it still produces an error. Is there any way to write this to get it to work in Visual Build Pro?

1st example:
Set doc = CreateObject("MSXML.DOMDocument")
doc.load(myfile.xml)
myXpath = "//element[@attribute]"
Set nodes = doc.selectNodes(myXpath)

2nd example:
myXpath = "//element[[@attribute]]"

Thank You!

kinook
08-23-2006, 09:45 PM
The attached sample works ok here (outputs the text of the step elements in the current project). Note that in the Script code field of a Run Script action, brackets don't need to be doubled since the entire field is already expected to be script code (brackets denote script expressions in other fields).
http://www.visualbuild.com/Manual/runscript.htm
http://www.visualbuild.com/Manual/scriptexpressions.htm

Albert
08-24-2006, 09:17 AM
Thank you for always replying so promptly to all of my posts. Here's something wierd. I came in this morning and I no longer get the errors. The script now works fine. I don't understand it and I won't question it.

Thank you for all your help!