我有一个xml文件:
deltaQuery="select Uid from User where lastmodify > '${dataimporter.last_index_time}'">
该xml文件没有<?xml...>等标签
我想读取出dataSource标签中driver url等值,写了一个类如下:
File file = new File("data_config.xml");
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder builder=dbf.newDocumentBuilder();
Document doc=builder.parse(file);
NodeList dataSource = doc.getElementsByTagName("dataSource");
System.out.println(dataSource.getLength());
for(int i=0;i<dataSource.getLength();i++)
{
Node node=dataSource.item(i);
System.out.println(node);
System.out.println(node.getNodeValue());
}
总是说读到的null。
求大牛指正。
另外:我想读取所有filed下的column 和name标签的值,该怎么写呢?