I have a simple XML
<task id ="MyMethod">
<taskParameter>"Redicted"</taskParameter>
<taskParameter>"ServerInitiated"</taskParameter>
</task>
<task id ="NoRedictedMethod">
<taskParameter>"NoRedicted"</taskParameter>
</task>
and I want to parse it with Java and I try to print them with the proper nesting
NodeList ParentList = doc.getElementsByTagName("task");
for (int i = 0; i < ParentList.getLength(); i++) {
System.out.println("Parent is "+ ParentList.item(i).getTextContent());
NodeList childList = ParentList.item(i).getChildNodes();
for (int j = 0; j < childList.getLength(); j++) {
System.out.println("Clild is "+ childList.item(j).getTextContent());
}
}
my results are not right. What am I doing wrong?
PS. I want to print something like that
Parent is MyMethod
Clild is Redicted
Clild is ServerInitiated
Parent is NoRedictedMethod
Clild is NoRedicted