用DOM读取XML文件例子(JAVA)        Document document = null;用DOM读取XML文件例子(JAVA)
用DOM读取XML文件例子(JAVA)        DocumentBuilderFactory factory 
= DocumentBuilderFactory.newInstance();用DOM读取XML文件例子(JAVA)
{
用DOM读取XML文件例子(JAVA)            DocumentBuilder builder 
= factory.newDocumentBuilder();
用DOM读取XML文件例子(JAVA)            document 
= builder.parse(configPath);
用DOM读取XML文件例子(JAVA)            Node rootNode 
= document.getFirstChild();
用DOM读取XML文件例子(JAVA)            System.
out.println(rootNode.toString());
用DOM读取XML文件例子(JAVA)            NodeList logFileList = rootNode.getChildNodes();
{
用DOM读取XML文件例子(JAVA)                Node curNode 
= logFileList.item(i);
用DOM读取XML文件例子(JAVA)                System.
out.println("Log file" + i + " : " + curNode.toString());
用DOM读取XML文件例子(JAVA)                NamedNodeMap map 
= curNode.getAttributes();
{
用DOM读取XML文件例子(JAVA)                    System.
out.println("Log file" + i + " :key: " + map.item(j).getNodeName());
用DOM读取XML文件例子(JAVA)                    System.
out.println("Log file" + i + " :value: " + map.item(j).getNodeValue());
用DOM读取XML文件例子(JAVA)                }

用DOM读取XML文件例子(JAVA)                NodeList columns 
= curNode.getChildNodes();
{
用DOM读取XML文件例子(JAVA)                    System.
out.println("column" + j + " : " + columns.item(j).toString());
用DOM读取XML文件例子(JAVA)                }

用DOM读取XML文件例子(JAVA)            }

{
用DOM读取XML文件例子(JAVA)            e.printStackTrace();
{
用DOM读取XML文件例子(JAVA)            e.printStackTrace();
{
用DOM读取XML文件例子(JAVA)            e.printStackTrace();
用DOM读取XML文件例子(JAVA)        }


XML文件内容:

用DOM读取XML文件例子(JAVA)<?xml version="1.0" encoding="UTF-8"?>
用DOM读取XML文件例子(JAVA)
<LOG_MAPPING>
用DOM读取XML文件例子(JAVA)    
<LOG_FILE fileNamePattern="ad.+\.log" class="com.nec.jp.bigm.log.ADLogCounter">
用DOM读取XML文件例子(JAVA)        
<column name="date"/>
用DOM读取XML文件例子(JAVA)        
<column name="carrier"/>
用DOM读取XML文件例子(JAVA)        
<column name=""/>
用DOM读取XML文件例子(JAVA)    
</LOG_FILE>
用DOM读取XML文件例子(JAVA)    
<LOG_FILE fileNamePattern="access.+\.log" class="com.nec.jp.bigm.log.ADLogCounter">
用DOM读取XML文件例子(JAVA)        
<column name=""/>
用DOM读取XML文件例子(JAVA)        
<column name=""/>
用DOM读取XML文件例子(JAVA)        
<column name=""/>
用DOM读取XML文件例子(JAVA)    
</LOG_FILE>
用DOM读取XML文件例子(JAVA)
</LOG_MAPPING>
用DOM读取XML文件例子(JAVA)

相关文章: