JAVA¶ÁÈ¡XMLÎļþ JDK1.4
XML code:
<?xml version="1.0" encoding="UTF-8" ?>
<Rot>
<name>ÕÅÈý</name>
<age></age>
<Tor>
Java code:
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse (new File(filePath));
doc.getDocumentElement ().normalize ();
NodeList nodeList = doc.getElementsByTagName("Rot");
for(int i=0;i<nodeList.getLength();i++){
Node fatherNode=nodeList.item(i);
if(fatherNode.getNodeType()==Node.ELEMENT_NODE){
Element element = (Element)fatherNode;
NodeList nList = element.getElementsByTagName("age");
Element eElement = (Element)nList.item(0);
eElement.getTextContent();//ÕâÑùûÎÊÌ⣬µ«ÊÇjdk1.4²»Ö§³Ö
eElement.getFirstChild().getNodeValue();//1.4Ö§³Öµ«ÊÇ,Èç¹ûÄǸöage½ÚµãÀïÃæÃ»ÓÐÖµµÄ»° Ö±½Ó±¨¿ÕÖµÒì³£
}
}
µ«ÊÇÏÖÔÚ ±ØÐëÒªÔÚJDK 1.4µÄ»·¾³ÏÂÔËÐÐ
Çó½â.......
·Ç³£¼òµ¥£¬Äã¿ÉÒÔ
Ïà¹ØÎÊ´ð£º
ÎÊÌâÃèÊö£ºÐ´ÈÕÖ¾¹¦ÄÜ£¬Ð´ºÃµÄдÈÕÖ¾·þÎñ£¬ÆäËûÓû§Í¨¹ýhttpµ÷Ó÷þÎñ£¬´«Èë²ÎÊý£¬È»ºó¼Ç¼ÈÕÖ¾£¬
ÎҵķþÎñ¸ÃÔõôд£¬ ±ðÈËÔõôͨ¹ýhttpµ÷ÓÃÎҵķþÎñ£¬ÎÒÓÃwebserviceдºÃÁËÒ»¸ö£¬¿ÉÊDz¢·¢ÓÐÉÏÏߣ¬Ïë¸ÄÓ ......
ÎÒÏÖÔÚÓÃstruts2¿ò¼Ü,ÐèҪʹÓÃajaxʵÏÖ¾Ö²¿Ë¢Ð£¬µ«ÊÇ´ÓÈÝÆ÷Àï·µ»ØµÄÖµ²»ÖªµÀÔõô´Óstruts.xmlÅäÖÃÎļþÀïÓ³Éäµ½jspÒ³ÃæÀÒÔǰservletÀïдout.orint("xxxxx")¾Í¿ÉÒԵõ½~£¬µ«ÊÇÏÖÔÚÓÃstruts¾Í²»ÖªµÀÔõôР......
Êý¾Ý¿â±íÖÐÓÐÒ»ÁУ¨TranXml£©ÀàÐÍÊÇxml£¬´æ´¢µÄÊÇÀàËÆ
<fathernode>
<a>aaa
</a>
<b>bbb
</b>
</fathernode>
µÄÐÅÏ¢£¬²¢ÇÒͨ¹ý²éѯ·½· ......
¹¤×÷ÐèÒª Çó´ó¼Ò°ïæд¸ö³ÌÐò
ÎÒÊÇѧC++µÄ ²»¶®JAVA
±àдһ¸öJavaÓ¦ÓóÌÐò£¬¶ÔÓÚ¸ø¶¨µÄÒ»¸ö×Ö·û´®µÄ¼¯ºÏ£¬¸ñʽÈ磺
{aaa bbb ccc}£¬ {bbb ddd}£¬{eee fff}£¬{ggg}£¬{ddd hhh}
ÒªÇ󽫯äÖн»¼¯²»Îª¿ÕµÄ ......