XML DOM方式

韩 第10讲

 

 1 public static TxmlCatalinaLocalhost ParseZ(String _strFilePathName) throws Exception
 2 {
 3     DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
 4     DocumentBuilder db = dbf.newDocumentBuilder();
 5     Document doc = db.parse(_strFilePathName);
 6      
 7     Node firstChild = doc.getFirstChild();
 8     if (firstChild.getNodeType() == Node.ELEMENT_NODE)
 9     {
10         TxmlCatalinaLocalhost cl = new TxmlCatalinaLocalhost();
11          
12         Element ele = (Element)firstChild;
13         cl.path = ele.getAttribute("path");
14         cl.docBase = ele.getAttribute("docBase");
15         System.out.println(cl.path);
16         System.out.println(cl.docBase);
17         return cl;
18     }
19      
20     return null;
21 }

 

Z

 

posted @ 2015-11-22 20:59  codeskill_android  阅读(127)  评论(0编辑  收藏  举报