Parsing code called twice
Somehow my code is being called twice with the result that everything has the same name twice (multiple names are legal according to the DTD).
My parsing code looks like this:
public Channel getChannel(Node channelnode)
{
Channel channel;
NodeList channelchildren;
Element channelelement;
channelelement = (Element)channelnode;
if(channelelement.hasAttribute("id"))
{
channel = new Channel(channelelement.getAttribute("id"));
channelchildren = channelnode.getChildNodes();
for(int i = 0 ; i < channelchildren.getLength() ; i++)
{
if(channelchildren.item(i).getNodeType() == Node.ELEMENT_NODE)
{
if(channelchildren.item(i).getNodeName().equals(("display-name")))
{
channel.addDisplayname(getDisplayname(channelchildren.item(i)));
}
if(channelchildren.item(i).getNodeName().equals(("icon")))
{
}
if(channelchildren.item(i).getNodeName().equals(("url")))
{
}
}
}
}
else
{
channel = null;
}
return channel;
}
public String getDisplayname(Node displaynamenode)
{
Element displaynameelement;
Node displayname;
displaynameelement = (Element)displaynamenode;
displayname = displaynamenode.getFirstChild();
if(displaynameelement.hasAttribute("lang"))
{
return displayname.getNodeValue();
}
else
{
return displayname.getNodeValue();
}
}
The code above is used to parse part of this tag in my XML file:
<channel id="001.tv.tv2.dk">
<display-name>TV 2</display-name>
<icon src="http://tv.tv2.dk/images/logo/1.gif" />
</channel>
The problem is that the addDisplayname in the Channel class is somehow called twice even though there is only one <display-name> tag.
Any help figuring out what is happening will be greatly appreciated.

