xpath and html value (javascript)

Let's say I want to check if "xpath html value" is equal to some text in a website.


html/body/div/div[7]/table/tbody/tr[2]/td value = "some text" 

How do I get it?


You can use document.evaluate to do this:

var value = document.evaluate('html/body/div/div[7]/table/tbody/tr[2]/td', document.documentElement, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent;

Have a look here for some more information on how to set up an iterator and iterate through a number of nodes, in case you need to get the value of more than just one td in the tr.

Need Your Help

how to make my variable safe for database insertion?

php content-management-system

I have a variable which I need to strip of sybols before inserting into my database, any ideas how I would add the mysql_real_escape_string() function to my existing code?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.