用个标准的XML文档测试一下:
<?xml version="1.0"?>
<purchaseOrder orderDate="1999-10-20">
<shipTo country="US">
<name>Alice Smith</name>
<street>123 Maple Street</street>
<city>Cambridge</city>
<state>MA</state>
<zip>12345</zip>
</shipTo>
<billTo country="US">
<name>Robert Smith</name>
<street>8 Oak Avenue</street>
<city>Cambridge</city>
<state>MA</state>
<zip>12345</zip>
</billTo>
<items>
<item partNum="242-NO" >
<productName>Nosferatu - Special Edition (1929)</productName>
<quantity>5</quantity>
<USPrice>19.99</USPrice>
</item>
<item partNum="242-MU" >
<productName>The Mummy (1959)</productName>
<quantity>3</quantity>
<USPrice>19.98</USPrice>
</item>
<item partNum="242-GZ" >
<productName>Godzilla and Mothra: Battle for Earth/Godzilla vs. King Ghidora</productName>
<quantity>3</quantity>
<USPrice>27.95</USPrice>
</item>
</items>
</purchaseOrder>
---------------------------
用JAXB吧.里面有例子,你可以照着例子做.把SCHEMA->JAVA OBJ
<?xml version="1.0"?>
<purchaseOrder orderDate="1999-10-20">
<shipTo country="US">
<name>Alice Smith</name>
<street>123 Maple Street</street>
<city>Cambridge</city>
<state>MA</state>
<zip>12345</zip>
</shipTo>
<billTo country="US">
<name>Robert Smith</name>
<street>8 Oak Avenue</street>
<city>Cambridge</city>
<state>MA</state>
<zip>12345</zip>
</billTo>
<items>
<item partNum="242-NO" >
<productName>Nosferatu - Special Edition (1929)</productName>
<quantity>5</quantity>
<USPrice>19.99</USPrice>
</item>
<item partNum="242-MU" >
<productName>The Mummy (1959)</productName>
<quantity>3</quantity>
<USPrice>19.98</USPrice>
</item>
<item partNum="242-GZ" >
<productName>Godzilla and Mothra: Battle for Earth/Godzilla vs. King Ghidora</productName>
<quantity>3</quantity>
<USPrice>27.95</USPrice>
</item>
</items>
</purchaseOrder>
---------------------------
用JAXB吧.里面有例子,你可以照着例子做.把SCHEMA->JAVA OBJ
解决方案 »
- entity manager 对象null值异常
- 关于hibernate SessionFactory 的配置 小问题
- 关于java下载文件问题 希望能帮的就帮一下
- 去购物了
- struts datasoure
- HTTP Status 500:The server encountered an internal error () that prevented it from fulfilling this request.
- DOM 与 SAX 我到底该用哪个呢?
- 请问各位大侠,如何在Jsp中使用JDBC来联结Foxpro?
- tomcat5.0.24如何连接ms sqlserver2000和mysql,在线等,对了就结铁(90分)
- jdom解析器的小问题。
- 关于如何在applet中实现打印图形的问题
- 各位有没有人用过ORACLE的一套j2ee开发组件?欢迎讨论
你的
String string = "<?xml version='1.0'?><bookname>java</bookname>";
试试看因该可以了!
错误提示:File "<?xml version='1.0'?><book>……"not found.