Как я могу использовать Java Xpath, чтобы получить значение 2-го тега "c" d и f как 2
<a>
<b>
<c type="lol">
<d>1</d>
<f>2</f>
</c>
<c type="lol">
<d>2</d>
<f>2</f>
</c>
<c type="h">
<d>v</d>
<f>d</f>
</c>
</b>
</a>
{
DocumentBuilderFactory dBFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dB = dBFactory.newDocumentBuilder();
Document doc = dB.parse(url);
System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
XPathFactory factory = XPathFactory.newInstance();
XPath xpath = factory.newXPath();
XPathExpression expr=null;
String text= null;
expr= xpath.compile("//a/b/c[@type='lol']/d/text()");// this gets the first value
text = (String) expr.evaluate(doc, XPathConstants.STRING);
}
Как я могу использовать Java Xpath, чтобы получить значение 2-го тега "c" d и f как 2