0

エラーが発生しています:

org.xml.sax.SAXException: expected </taxonomy>

親子関係を作成するためのxmlを作成しています。私のコード:

public void createXML(Map mp) throws SAXException, TransformerConfigurationException{

System.out.println("the size of the mp is              :   "+mp.size());
String parent,child,li,child1;
  li = "li";
Set keySetFinal = mp.keySet();
System.out.println("the size of the key set is : "+keySetFinal.size());
// Get Iterator of keySet
Iterator<String> iterator = keySetFinal.iterator(); 
XMLDocument xml = new XMLDocument(new StreamResult("C:\\Program Files\\Notepad++\\XML_FOR_TAX.xml"), false, 4, null);
  xml.startDocument();
  {
    try {
        xml.startElement("taxonomy");

      while(iterator.hasNext()){          
            //  System.out.println("loop started");
            parent = iterator.next();
            NodeList childNodes = (NodeList) mp.get(parent);
            System.out.println("the size of the child list for this iteration is: "+ childNodes.getLength());
            xml.addElement("li", parent);
            System.out.println("key in the xml creation function is: "+parent);

                for (int i = 0; i < childNodes.getLength(); i++){
                     if (childNodes.item(i).getNodeType() == Node.ELEMENT_NODE){
                     Element child_1 = (Element)childNodes.item(i); 
                     child1 = child_1.getAttribute("name");
                     System.out.println("child now is : "+child1);
                     xml.startElement("ul");
                     xml.addElement("li", child1);
                     xml.endElement("ul");
                     }                     
                     }
                xml.endElement("li");
      }



    }catch (SAXException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
    xml.endElement("taxonomy"); 
            }
      xml.endDocument();
  }
4

0 に答える 0