XML: 一般文件写和加载库(Java),xmljava,http://www.c
分享于 点击 21094 次 点评:139
XML: 一般文件写和加载库(Java),xmljava,http://www.c
http://www.codeproject.com/KB/library/GenericXMLFile.aspx
[Java]代码
//// This is a simple example how the library can be used//GenericXml gx = new GenericXml();IGeneric xmldata = gx.createNewDatamodel();IGeneric cat = gx.createCategory(xmldata, "Manager", "John Blake", Type.TEXT);IGeneric entry = gx.createEntry(cat, "Employee", "Susan Meyer", Type.TEXT, null);IGeneric data = gx.createData(entry, "Salary", "4.653,00", Type.NUMBER);gx.createTag(data, new String[] {"confidential"});System.out.println(gx.toString()); // debug outputgx.saveData(new File ("c:\\temp\\generic.test.xml")); // save to file
[XML]代码
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><xmldatafile name="xmldatadefault"> <category key="Manager" value="John Blake" type="text"> <entry key="Employee" value="Susan Meyer" type="text"> <data value="4.653,00" key="Salary" type="number"/> <tag value="confidential"/> </data> </entry> </category></xmldatafile>
用户点评