1

This is my XPath operation:

XPathExpression source = xpath.compile("@source/text()"); 

I'm looping over a node list created by another XPath operation on the main document. So I'm calling source like this:

(NodeList)source.evaluate(list.item(x), XPathConstants.NODESET); 

The resulting node list is always empty. Why is that?

1 Answer 1

2

@source/text() is not valid: @source is an attribute, and attributes do not have child nodes - text or otherwise.

You should use simply @source.

(Seeing the XML would help, but I am assuming that list.item(x) is an XML element that can have a source attribute)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.