Leviathanbow
New Member
I have written a code that can save data into xml. NOW I want to use that stored xml and import its data in a table I have in the form. the problem is: the code is with no error but the table is not field with the xml data here is my code: \[code\] private void jPanel4ComponentShown(java.awt.event.ComponentEvent evt) { // TODO add your handling code here: DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); try{ DocumentBuilder builder = domFactory.newDocumentBuilder(); Document doc = builder.parse("D:\\test.xml"); Element root = doc.getDocumentElement(); NodeList nodelist1 = root.getElementsByTagName("FrameDefinitionSection"); String[] st= new String[4]; for(int i=0;i<nodelist1.getLength();i++) { Node node=nodelist1.item(i); st[0]= node.getChildNodes().item(1).getTextContent(); st[1]= node.getChildNodes().item(3).getTextContent(); st[2]= node.getChildNodes().item(5).getTextContent(); st[3]= node.getChildNodes().item(7).getTextContent(); ((DefaultTableModel) jTable1.getModel()).addRow(st); } } catch(Exception ex) { System.out.print("error"); }} \[/code\]and here is my xml file : the table should show the nodes in this xml into fields of table but it does not work ! :\[code\]<?xml version="1.0" encoding="UTF-8" standalone="no"?><FrameDefinitionSection><FrameNameAndElements><FrameName>here is the frame's name</FrameName><FrameElements>its element</FrameElements></FrameNameAndElements><FrameDefinition><Definition>the definition of the frame</Definition></FrameDefinition><FrameExampleSentences><ExampleSentences>its example as well</ExampleSentences></FrameExampleSentences></FrameDefinitionSection>\[/code\]