Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Read XML File using DOM

  Asked By: Kuhaylah    Date: Mar 26    Category: Java    Views: 960

I want to read all my servers from this XML file. Here is the
sample XML file. I would like to read the nodenames of all the
servers(like Server1, Server2,Server3) and populate in a combobox.
Once I select the Server in the combo box then I want to populate
the username and password in a text box. Please let me know how to

Here is the code I have so far...

DocumentBuilder builder = DocumentBuilderFactory.newInstance
Document doc = builder.parse(file);

// Find the tags of interest
NodeList listofServers = doc.getElementsByTagName
int totalServers=listofServers.getLength();
for(int i = 0; i < totalServers; i++) {
Node serverNode=listofServers.item(i);

Element serverElement = (Element)instanceNode;


<?xml version="1.0" encoding="UTF-8"?>



















No Answers Found. Be the First, To Post Answer.

Didn't find what you were looking for? Find more on Read XML File using DOM Or get search suggestion and latest updates.