问题描述
总是报Theprocessinginstructiontargetmatching"[xX][mM][lL]"isnotallowed.的错,不知道怎么改?求助!!!importjava.io.FileWriter;importjava.io.IOException;importjava.util.Iterator;importjava.util.List;importorg.dom4j.Document;importorg.dom4j.DocumentException;importorg.dom4j.Element;importorg.dom4j.io.SAXReader;importorg.dom4j.io.XMLWriter;publicclassTest{publicstaticvoidmain(String[]args){try{SAXReaderreader=newSAXReader();Documentdocument=reader.read(Test.class.getResourceAsStream("/myfile2.xml"));Elementroot=document.getRootElement();for(Iteratori=root.elementIterator();i.hasNext();){Elementelement=(Element)i.next();System.out.println(element.getName());}//for(Elemente1:(List<Element>)root.elements())//{//System.out.println(e1.getName()+":"+e1.getTextTrim());//}Elementee=document.addElement("gender").addText("man");try{XMLWriterwriter=newXMLWriter(newFileWriter("c:/myf.xml"));writer.write(document);writer.close();}catch(IOExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}}catch(DocumentExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}}}org.dom4j.DocumentException:Erroronline1ofdocument:Theprocessinginstructiontargetmatching"[xX][mM][lL]"isnotallowed.Nestedexception:Theprocessinginstructiontargetmatching"[xX][mM][lL]"isnotallowed.atorg.dom4j.io.SAXReader.read(SAXReader.java:482)atorg.dom4j.io.SAXReader.read(SAXReader.java:343)atcom.yjp2.Test.main(Test.java:31)
解决方案
解决方案二:
把xml内容贴出来。
解决方案三:
XML的内容很简单<?XMLverson="1.0"encoding="utf-8"?><school><age>12</age><name>小明</name><number>07421</number></school>
解决方案四:
<?XMLverson="1.0"encoding="utf-8"?>第一行错了,异常如是说,
解决方案五:
xml小写
解决方案六:
<?xmlversion="1.0"encoding="utf-8"?>注意单词和规范
解决方案七:
OK了
解决方案八:
该回复于2010-12-21 09:59:17被版主删除
解决方案九:
对,要小写