public Document createDocument() {
        Document document = DocumentHelper.createDocument();
        Element root = document.addElement( "root" );        Element author1 = root.addElement( "author" )
            .addAttribute( "name", "James" )
            .addAttribute( "location", "UK" )
            .addText( "James Strachan" );
        
        Element author2 = root.addElement( "author" )
            .addAttribute( "name", "Bob" )
            .addAttribute( "location", "US" )
            .addText( "Bob McWhirter" );        return document;
    }

解决方案 »

  1.   

    汗,你贴的代码也不是处理我的文档的啊。
    我主要想问的是这部分怎么创建:
    <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:noNamespaceSchemaLocation="Config.xsd">
      

  2.   

    Document doc = DocumentHelper.createDocument();
    Element root = doc.addElement("root");
    Namespace ns = new Namespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
    root.add(ns);
    root.addAttribute("xsi:noNamespaceSchemaLocation", "Config.xsd");
      

  3.   

    I can see zcjl finally! I can see the hope.