I am using the following XPath query to search the name of the author of a book and return the book name when it matches the author.
String rawXPath = String.format("//book[author= '%s']/bookname/text()", authorBook);
XPathFactory factory = XPathFactory.newInstance();
XPath xpath = factory.newXPath();
XPathExpression expr
= xpath.compile(rawXPath);
Object result = expr.evaluate(doc, XPathConstants.NODESET);
NodeList nodes = (NodeList) result;
for (int i = 0; i < nodes.getLength(); i++) {
System.out.println(nodes.item(i).getNodeValue());
}
how to modify the search so that I can search in the content ...../content(node name) for a specific word.
Example: String inside the xml content variable: "This book contains the glory and history of our forefathers. And the impact of it in our daily life is immense."
Now I want to search for the word "daily". If it matches daily it will retun me the book name/author name watever the user wants.
Thanks