I have this xml file:
<root>
<application>
<interface />
<interface />
</application>
<datatransmit>
<interface />
</datatransmit>
</root>
What I am trying to do is first do a loop through the interfaces within the <application>
tags and then another loop through the interfaces withing the <datatransmit>
tags.
I tried this with this Java code:
NodeList application = doc.getElementsByTagName("application");
for (int i = 0; i < application.getLength(); i++) {
NodeList interfaces = doc.getElementsByTagName("interface");
for (int j = 0; j < interfaces.getLength(); j++) {
do some stuff...
}
}
I noticed that with this loop, it goes through a loop of all the interface elements. Not just the interfaces withing the application
tags but also the interfaces within datatransmit
.
What would be a way to solve this?