I'm creating a parser and I use the expression //html/body//div[@id='bodyContent']/s[1] to take the first node with tag <p>.
But if I have to take all nodes, wh开发者_如何学Goat expression should I write?
Thanks
You want to extract all <p> tags within div with id bodyContent?
//html/body//div[@id='bodyContent']//p
or just all <p> tags?
//p
For instance, jaxen is a good library for xpath. You can use e.g.,
List<Node> nodes = new DOMXPath("//p").selectNodes(document);
for (Node node : nodes) {
// do something with the matched nodes
node.getValue();
}
加载中,请稍侯......
精彩评论