|
<! DOCTYPE db-config SYSTEM "db-config.dtd">
<db-config>
<db-info id = "oracle">
<db-driver> oracle.jdbc.driver.OracleDriver </ db-driver>
<db-url> jdbc: oracle: thin: @ 192.168.1.78: 1521: ORDBA </ db-url>
<db-userName> scott </ db-userName>
<db-userPassword> tiger </ db-userPassword>
</ db-info>
<db-info id = "mysql">
<db-driver> com.mysql.jdbc.Driver </ db-driver>
<db-url> jdbc: mysql: // localhost: 3306 / jive? useUnicode = true& characterEncoding = UTF-8 </ db-url>
<db-userName> root </ db-userName>
<db-userPassword />
</ db-info>
</ db-config>
I used the DOM to parse the xml document shown above, but there was a rather depressed place
I use
Element root = doc.getDocumentElement ();
Get the root element, next I use
NodeList nodeList = root.getElementsByTagName ("db-info");
To get its "db-info" child nodes,
It stands to reason that I continue to get its
NodeList nodeChileList = lement.getElementsByTagName ("db-driver");
But why use it when getting the "db-driver" element:
nodeChileList.item (0) .getFirstChild (). getNodeValue () method?
Instead of using the nodeChileList.item (0) .getNodeValue () method directly?
The getFirstChild () method is literally understood to get its first child node ??? |
|