How to compare an value using xpath?

i am currently doing java and html, i have to check some values from the website against my database. i would like to ask if XPATH has such function like "is text present" or "get text = data" rather than get element, is there something to check if the value is there or something?

Answers


You can use boolean method in XPath.

For example, lets say your XML is this

<?xml version="1.0" >
<persons>
<person>
  <name>Peter</name>
  <sex>MALE</sex>
  <age>25</age>
</person>
</persons> 

You can use the boolean method as,

boolean(/persons/person[name = 'Peter'])

Need Your Help


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.