Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please Help: XPath attribute values 1

Status
Not open for further replies.

problematic329

IS-IT--Management
Dec 12, 2007
1
US
Is there a way to compare an attribute value to a variable? For example I have the path:

/employees/employee[@id='1']/name

But what if I do not know the value for the attribute id or want to change this by modifying a variable in javascript. I've tried:

var number = 1;

/employees/employee[@id=number]/name

This does not seem to work.

Any assistance is greatly appreciated!
 
>var number = 1;
>/employees/employee[@id=number]/name
Construct the xpath string like this.
[tt]var number=1;
var sxpath;
sxpath="/employees/employee[@id='"+number+"']/name";[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top