java代码如下:
1 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 2 DocumentBuilder builder = null; 3 try { 4 builder = factory.newDocumentBuilder(); 5 Document doc = builder.parse(new File("test.xml")); 6 System.out.println(doc); 7 } catch (ParserConfigurationException e) { 8 e.printStackTrace(); 9 } catch (SAXException e) { 10 e.printStackTrace(); 11 } catch (IOException e) { 12 e.printStackTrace(); 13 }
xml代码如下:
<?xml version="1.0" encoding="UTF-8"?> <Layout> <name>Smith</name> <age>25</age> <sex>male</sex> </Layout>
打印doc为[#Document:null]
我想知道怎样才能使doc打印出来有内容呢?百度,Google翻遍了都没有解决问题,园豆不多,各位园友帮帮忙啊!
我也遇到了,你最后怎么解决的呢?
我也遇到了,你最后怎么解决的呢?