Xml
If the XML file contains Chinese, you need to add
<?xml version= "1.0" encoding= "GB2312"?> can be resolved
For instance:
A XML file like this:
< action >
< insert target Node number = "001" Insert mode = "5" >
< Insert Item Property name = "Name" VALUE = "China"/>
< Insert Item Property name = "Name" value = "/>"
</Insert >
</Action >
Import Javax.xml.parsers.DocumentBuilder;
Import Javax.xml.parsers.DocumentBuilderFactory;
Import org.w3c.dom.*;
public class xml2oth{
Documentbuilderfactory factory = Documentbuilderfactory.newinstance ();
Documentbuilder builder = Factory.newdocumentbuilder ();
Element root = Doc.getdocumentelement ();
NodeList Allnode = Root.getchildnodes ();
for (int i = 1; i < allnode.getlength (); i + = 2) {//
ELEMENT item = (element) allnode.item (i);
Xml2dbmsbean _bean = new Xml2dbmsbean ();
System.out.println (Item.getnodename ());
names = Item.getelementsbytagname ("Insert item");/set to your own
}
}