Using Variables in XPath Expressions

  • Thread starter Thread starter rustyfancy
  • Start date Start date
R

rustyfancy

I have a textBox that contains a string values. I need to take this
string and use it as criteria for an XPath Expression. Here's what I
have. Why isn't it working???

string s = textBox1.Text;
XPathExpression expr;
expr = myXPathNavigator.Compile("/NewDataSet/note[@to=$s]");

----Matt
 
Hi Matt,

Can you check to see if something similar to the below works -

string filter = textBox1.Text;
String xpathExpression =
String.Format("/NewDataSet/note[@to='{0}']", filter);
XPathExpression expr = myXPathNavigator.Compile(xpathExpression);

Regards,
Aravind C

rustyfancy said:
I have a textBox that contains a string values. I need to take this
string and use it as criteria for an XPath Expression. Here's what I
have. Why isn't it working???

string s = textBox1.Text;
XPathExpression expr;
expr = myXPathNavigator.Compile("/NewDataSet/note[@to=$s]");

----Matt



----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
=---
 
Back
Top