java ¶Áдxml
ʹÓÃDOM·½Ê½£¬Java½âÎöXML»ù±¾²½Öè:
Ê×ÏÈ£¬ÎÒÃÇÐèÒª½¨Á¢Ò»¸ö½âÎöÆ÷¹¤³§¡£
DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();
È»ºó¿ÉÒÔÀûÓÃÕâ¸ö¹¤³§À´»ñµÃÒ»¸ö¾ßÌåµÄ½âÎö¶ÔÏó¡£
DocumentBuilder builder=dbf.newDocumentBuilder();
DocumentBuilderµÄParse()·½·¨½ÓÊÜÒ»¸öXMLÎĵµÃû×÷ΪÊäÈë²ÎÊý£¬·µ»ØÒ»¸öDocument¶ÔÏó¡£Document¶ÔÏó´ú±íÁË Ò»¸öXMLÎĵµµÄÊ÷Ä£ÐÍ¡£
Document doc=builder.parse("candiate.xml");
ʹÓÃDocument¶ÔÏóµÄgetElementsByTagName()·½·¨£¬ÎÒÃÇ¿ÉÒԵõ½Ò»¸öNodeList¶ÔÏó£¬ËûÊÇXMLÎĵµÖеıêÇ©ÔªËØ ÁÐ±í£¬¿ÉÒÔʹÓÃNodeList¶ÔÏóµÄitem()·½·¨À´µÃÁбíÖеÄÿһ¸öNode¶ÔÏó¡£
NodeList nl=doc.getElementsByTagName("PERSON");
Element node=(Element)nl.item(i);
×îºó£¬ÎÒÃÇ»áʹÓÃNode¶ÔÏóµÄgetNodeValue()·½·¨Ìáȡij¸ö±êÇ©ÄÚµÄÄÚÈÝ¡£
node.getElementsByTagName("NAME").item(0).getFirstChild().getNodeValue()
ÍêÕû³ÌÐò´úÂë:
import javax.xml.parsers.*;
import org.w3c.dom.*;
public class dom {
public static void main(String args[]){
String uri=args[0];
try{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();//½¨Á¢Ò»¸ö½âÎöÆ÷¹¤³§¡£
DocumentBuilder builder=factory.newDocumentBuilder();//»ñµÃÒ»¸ö¾ßÌåµÄ½âÎö¶ÔÏó¡£
Document doc=builder.parse(uri);//·µ»ØÒ»¸öDocument¶ÔÏó¡£
System.out.println(doc.getImplementation());
NodeList nl =doc.getElementsByTagName("PERSON");//µÃµ½Ò»¸öNodeList¶ÔÏó¡£
for (int i=0;i<nl.getLength();i++){
Element node=(Element) nl.item(i);//µÃÁбíÖеÄÿһ¸öNode¶ÔÏó¡£
System.out.print("NAME: ");
System.out.println (node.getElementsByTagName("NAME").item(0).getFirstChild().getNodeValue());
System.out.print("ADDRESS: ");
System.out.println (node.getElementsByTagName("ADDRESS").item(0).getFirstChild().getNodeValue());
System.out.print("TEL: ");
System.out.println (node.getElementsByTagName("TEL").item(0).getFirstChild().getNodeValue());
System.out.print("FAX: ");
System.out.println (node.getElementsByTagName("FAX").item(0).getFirstChild().getNodeValue());
System.out.print("EMAIL: ");
System.out.println (node.getElementsByTagName("EMAIL").ite
Ïà¹ØÎĵµ£º
Ôڳɹ¦ÊµÏÖJavaµ÷ÓÃC++Ö®ºó£¬½ÓÏÂÀ´Ïëµ½ÄÜ·ñͨ¹ýJNAʵÏÖJavaµ÷ÓÃFortran£¬½ñÌìÊÔÑéÁËһϣ¬»¹ÊDZȽÏÈÝÒ׵ġ£
ÍøÉÏÓÐÒ»¸öJavaµ÷ÓÃF95µÄÀý×Ó£¬µ«ÊÇÎÒ¿¼ÂDz»½öҪʵÏÖF95µÄµ÷Ó㬻¹ÒªÊµÏÖF77µÄµ÷Óã¬ËùÒÔ·ÑÁËһЩÖÜÕÛ¡£
ÎÊÌâµÄ¹Ø¼üÔÚÓÚF77Ϊ¹ý³ÌÃû×Ô¶¯Ìí¼ÓÁËÒ»¸öβ²¿µÄÏ»®Ïߣ¬ËùÒÔsub1Õâ¸ö¹ý³Ì£¬µ½JavaÒ»¶Ë£¬¾Í±ä³ÉÁËsub1_£¬ ......
±¾ÎÄת×Ôhttp://blog.csdn.net/nokiaguy/archive/2010/04/16/5493817.aspx
Ëõ·ÅͼÏñµÄ»ù±¾ÔÀíÊÇ´´½¨Ò»¸öÄ¿±ê´óСµÄ»²¼£¬È»ºó¶ÁȡԴͼÏñ£¬²¢½«¸ÃͼÏñ»æÖÆÕâ¸ö»²¼ÉÏ¡£ÎªÁËʹ³ÌÐòͨÓã¬Ô´Í¼ÏñºÍËõ·ÅºóµÄÄ¿±êͼÏñÓ¦Ó÷ֱðʹÓÃ
InputStreamºÍOutputStreamÀ´±íʾ£¬´úÂëÈçÏ£º
public
st ......
¡¡ÔÚJavaÓïÑÔÖУ¬ abstract class ºÍinterface ÊÇÖ§³Ö³éÏóÀඨÒåµÄÁ½ÖÖ»úÖÆ¡£ÕýÊÇÓÉÓÚÕâÁ½ÖÖ»úÖƵĴæÔÚ£¬²Å¸³ÓèÁËJavaÇ¿´óµÄ ÃæÏò¶ÔÏóÄÜÁ¦¡£abstract classºÍinterfaceÖ®¼äÔÚ¶ÔÓÚ³éÏóÀඨÒåµÄÖ§³Ö·½Ãæ¾ßÓкܴóµÄÏàËÆÐÔ£¬ÉõÖÁ¿ÉÒÔÏ໥Ìæ»»£¬Òò´ËºÜ¶à¿ª·¢ÕßÔÚ½ø ÐгéÏóÀඨÒåʱ¶ÔÓÚabstract classºÍinterfaceµÄÑ¡ÔñÏԵñȽÏËæ ......
Ëü¿ÉÒÔµ¼Èë¿â£¬µ÷ÓÃÍâÃæµÄ¿âº¯Êý£¬javaÓïÑԾͺܺõĵØÀûÓÃÁËÕâÒ»µã£¬jspÒ²¿ÉÒÔÔÚÍøÒ³Öе÷ÓÃjava±àдºÃµÄ³ÌÐò£¬ÒªÊ¹ÓÃjavabean±êÇ©
struts±¾Éí¾ÍÊǶÔjava¼¼ÊõÒ»¸ö°ü×°,°üÀ¨£¬html,jsp¼°±êÇ©,servlet¡£
hibernateÊDZðÈ˱àдºÃÓ³ÉäÊý¾Ý¿âµÄ¹¤¾ß£¬Æä´úÂ붼ÊÇÓÃjavaÓïÑÔ±àдµÄ£¬Ö»ÊÇΪÁË·½±ãÓû§Ê¹Óã¬Óû§Ö»Òªµ¼ÈëÆä¿â£¬µ÷ÓÃÆ ......