I am parsing definitions from a dictionary api. I have this line of xml
<dt>:any of a small genus (<it>Apteryx</it>) of flightless New Zealand birds with rudimentary wings, stout legs, a long bill, and grayish brown hairlike plumage</dt>
How would i get the full line of the dt element. My problem is that it doesn't work when it gets up to this part (Apteryx) because there are additional tags in the element. How would i get the whole dt element as one whole string. Here is my current code.
Element def = (Element) element.getElementsByTagName("def").item(0);
System.out.println(getValue("dt",def).replaceAll("[^\\p{L}\\p{N} ]", ""));
Where def is the element that holds the dt element.
And here is my getValue code
private static String getValue(String tag, Element element)
{
NodeList nodes = element.getElementsByTagName(tag).item(0).getChildNodes();
Node node = (Node) nodes.item(0);
return node.getNodeValue();
}
Sometimes there are multiple nested tags within the dt element