Reputation: 11251
How I can extract value Total topics
?
<?xml version="1.0"?>
<config>
<command param = "Total topics" > Check title
</command>
</config>
I know that for extracting value of Check title
I need such code:
XPathExpression expr = xpath.compile("//command/text()");
Object result = expr.evaluate(doc, XPathConstants.NODESET);
Help me with param, please.
Upvotes: 0
Views: 148
Reputation: 86
XPathExpression expr = xpath.compile("//command[@param]/text()");
Object result = expr.evaluate(doc, XPathConstants.NODESET);
I've not compiled it but to select an attribute you'll need to used @attributeName
after the node is selected.
Upvotes: 1
Reputation: 124255
How about using @
for attribute? Try with
XPathExpression expr = xpath.compile("//command/@param");
Upvotes: 0