1

i want to find nodes containg an attribute with a certain value in XML . I tried with a certain Xpath expression but it wont work..

String expression = ".*[@*[starts-with(., '"+search+"')]]";

Here the search is the variable which contains the value which i want to search. Can anyone tell me the right Xpath expression.

Thanks.

2

1 Answer 1

1

Your expression is correct, only the .* makes no sense.

String expression = "//*[@*[starts-with(., '"+search+"')]]";
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Tomalak..It was my ignorance.. After a long and hard trying out i found an answer myself.but dont know the efficient factor of the query but it gives the result as i wanted.If there is a better one please let me know. String expression ="//*[starts-with(@*,'"+search+"')] | //"+search+"";
Depending on what you want to do this is exactly what you need. ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.