Simpe XML question.  You can make yourself look smart!

I have the following xml file:
<?xml version="1.0"?>
<ToolConfig>
     <database_info></database_info>
     <spelling_info></spelling_info>
     <server_info></server_info>
     <concept_list></concept_list>
</ToolConfig>I have the following java program:
import java.io.*;
import org.w3c.dom.*;
import org.apache.xerces.parsers.DOMParser;
import org.xml.sax.SAXException;
public class ConfigParams
    public ConfigParams()
        String configFile = new String("C:\\tomcat\\webapps\\QueryTool\\WEB-INF\\ToolConfig.xml");
        try
            DOMParser parser = new DOMParser();
            parser.parse(configFile);
            org.w3c.dom.Document configDoc = parser.getDocument();
            NodeList nodeList = configDoc.getChildNodes();
            for (int j=0; j<nodeList.getLength(); j++)
                System.err.println(j+": "+nodeList.item(j).getLocalName());
            System.err.println("-----");
            Node topNode = nodeList.item(0);
            NodeList sectionNodes = topNode.getChildNodes();
            for (int j=0; j<sectionNodes.getLength(); j++)
                System.err.println(j+": "+sectionNodes.item(j).getLocalName());
            System.err.println("-----");
        catch (SAXException se)
            System.err.println("SAX EXCEPTION");
            se.printStackTrace();
        catch (IOException ioe)
            System.err.println("IO EXCEPTION");
            ioe.printStackTrace();
    public static void main(String[] args)
        ConfigParams cp = new ConfigParams();
}The program outputs the following:
0: ToolConfig
0: null
1: database_info
2: null
3: spelling_info
4: null
5: server_info
6: null
7: concept_list
8: null
-----My question is: Why does it find nine child nodes when I only have four child nodes in the XML file? Why is every other child node null?
Thanks,
Jon

Thanks. That was helpful. I changed the getLocalName() call to getNodeName() and now it makes more sense. I do have another question, though: what is a local node name? What is a qualified node name?
Thanks,
Jon
P.S. Or maybe I should just go Read The Fine Manual.

Similar Messages

Maybe you are looking for

  • Problems with remote app solution suggestion!

    Hello, I have been trying to get the Remote app to work on my windows 8 PC, but to no result. I am using an iPhone 5S. I believe the problem is that my PC is a desktop connected to the internet via ethernet. This is a very common issue. I spent aroun

  • Re: [iPlanet-JATO] Re: Href click & tiled view display

    Srinivas-- Remember, attachments don't come through on the forum. Please send them to the jatoteam@e... alias. Todd ----- Original Message ----- From: "Srinivas Chikkam" <srinivas.chikkam@w...> Sent: Thursday, July 19, 2001 5:26 AM Subject: [iPlanet-

  • How to get Case Sensitive Check Box at Search Page

    Hi Everyone, I am trying to get case sensitive check box at the bottom of the search page, for that we have to set any propert or we ahve to do anything else. Please Help!!!! Thanks, Amit

  • 10.1 T-Mo typing language selection problem z10.

    Z10STL100-3/10.1.0.2025  Ever since I installed the new software on Monday, I've had a problem with the languages on the phone. I have everything set up in English, with secondary Spanish keyboard input. I don't have the auto-detect turned on because

  • Issues with default program.

    I installed aSSD in my MacBookPro 13" and copied all of my files from my old hard drive to it and now all of my default programs are reseted. I can't open DMG files now it just asks me what program I want to open it with. same with PKG files. I tried