I'm working with this code, and don't know if how it's done is the best way.
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
Document XMLDoc = factory.newDocumentBuilder().parse(new URL(xmlFile).openStream());
NodeList linkNames = XMLDoc.getElementsByTagName("urlName");
for (int i=0; i < linkNames.getLength(); i++) {
Node curNode = linkNames.item(i);
NamedNodeMap attrs = curNode.getAttributes();
String currTag = curNode.getNodeName();
if(currTag.equals("urlName"))
urlName.add(i, linkNames.item(i).toString());
}
The xml looks like:
<?xml version="1.0" encoding="UTF-8"?>
<menu>
<link>
<urlName>whats new?</urlName>
<urlPath>getcurrent.jsp?page=whatsnew</urlPath>
<subLink>
<subUrlName>announcements</subUrlName>
<subUrlPath/>
</subLink>
</link>
</menu>
Any help would be great thanks.