title: Help on XML to JTable Please
body: <p>I am trying to learn how to import from XML to JTable.  I am analyzing the following code in an attempt to understand what is happening.  The problem is I am unable to figure out why am I failing to see any values in the JTable.  I am sure that the XML is being parsed using the DOMBuilder etc.  I have included the code and the XML file that I am using.<br>
  Many thanks in advance!  P.S.  Place the person.xml file into the project folder.</p>
  
  <pre><code>import java.io.*;
  import org.w3c.dom.*;
  import javax.xml.parsers.*;
  import org.xml.sax.*;
  import java.util.*;
  import javax.swing.*;
  import javax.swing.table.*;
  
  public class XMLInJTable extends AbstractTableModel {
          Vector data;
          Vector columns;
  
          public XMLInJTable() {
                  try {
                          DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                          DocumentBuilder db = dbf.newDocumentBuilder();
                          Document doc = db.parse("person.xml");
  
                          NodeList nl = doc.getElementsByTagName("Name");
                          NodeList n2 = doc.getElementsByTagName("Address");
                          NodeList n3 = doc.getElementsByTagName("ContactNo");
                          NodeList listOfPersons = doc.getElementsByTagName("person");
                          String data1 = "", data2 = "", data3 = "";
                          data = new Vector();
                          columns = new Vector();
                          for (int i = 0; i &lt; listOfPersons.getLength(); i++) {
                                  data1 = nl.item(i).getFirstChild().getNodeValue();
                                  data2 = n2.item(i).getFirstChild().getNodeValue();
                                  data3 = n3.item(i).getFirstChild().getNodeValue();
                                  String line = data1 + " " + data2 + " " + data3;
                                  StringTokenizer st2 = new StringTokenizer(line, " ");
                                  while (st2.hasMoreTokens())
                                          data.addElement(st2.nextToken());
                          }
                          columns.add("");
                          columns.add("");
                          columns.add("");
  
                  } catch (Exception e) {
                          e.printStackTrace();
                  }
          }
  
          public int getRowCount() {
                  return data.size() / getColumnCount();
          }
  
          public int getColumnCount() {
                  return columns.size();
          }
  
          public Object getValueAt(int rowIndex, int columnIndex) {
                  return (String) data.elementAt((rowIndex * getColumnCount())
                                  + columnIndex);
          }
  
          public static void main(String argv[]) throws Exception {
                  XMLInJTable t = new XMLInJTable();
                  JTable table = new JTable();
                  table.setModel(t);
                  JScrollPane scrollpane = new JScrollPane(table);
                  JPanel panel = new JPanel();
                  panel.add(scrollpane);
                  JFrame frame = new JFrame();
                  frame.add(panel, "Center");
                  frame.pack();
                  frame.setVisible(true);
          }
  }
  </code></pre>
  
  <p>person.xml</p>
  
  <pre><code>&lt;?xml version="1.0"  encoding="UTF-8"  standalone="no"?&gt;
  
  &lt;Person&gt;
  &lt;Name&gt;Angelina&lt;/Name&gt;
  &lt;Address&gt;Dehi&lt;/Address&gt;
  &lt;ContactNo&gt;111111&lt;/ContactNo&gt;
  
  &lt;Name&gt;Martina&lt;/Name&gt;
  &lt;Address&gt;Mumbai&lt;/Address&gt;
  &lt;ContactNo&gt;222222&lt;/ContactNo&gt;
  
  &lt;/Person&gt;
  </code></pre>
  
  <p>Edit* I managed to get it working, it was because the line:</p>
  
  <pre><code>NodeList listOfPersons = doc.getElementsByTagName("person");
  </code></pre>
  
  <p>contained a small letter p for "persons" whenever it should've been a capital P.  Now I've managed to display a single line of values for Angelina however it fails to display for Martina.  Need to figure that out now with some much appreciated help thanks =)</p>