Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

dom4j ½âÎö xml Àý×Ó

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
SAXReader reader = new SAXReader();
try {
          Document doc = reader.read("ParserSQL.xml");
        
} catch (DocumentException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
        Element sql = doc.getRootElement();
       
        List list = sql.selectNodes("½ÚµãµÄÃû×Ö");
    for (int i = 0; i < list.size(); i++) {
         Element node1 = (Element) list.get(i);
        System.out.println(node1);
        List list1 = node1.elements();
   }


Ïà¹ØÎĵµ£º

VC½âÎöXML ʹÓÃCMarkupÀà½âÎöXML

(Ò») ÏȽ²Ò»ÏÂXMLÖеÄÎïÊâ×Ö·û£¬ÊÖ¶¯ÌîдʱעÒâһϡ£
×Ö·û                   ×Ö·ûʵÌå
&                     ......

(4).¶ÁÈ¡XMLÎļþ

//¶ÁÈ¡XMLÎļþ
//1¡¢LoadfromFile×°ÈëXMLÎļþ
//2¡¢Ö¸¶¨Â·¾¶£¬¼¤»î¶ÁÈ¡
//3¡¢´ÓÄÚ´æÁ÷¶ÁÈ¡
//4¡¢´ÓÍøÂçÉÏÖ±½Ó»ñÈ¡
//1¡¢LoadfromFile×°ÈëXMLÎļþ
procedure TForm1.Button1Click(Sender: TObject);
begin
XMLDocument1.LoadfromFile('c:\temp\test.xml');
// XMLDocument1.Active := True;
Memo1.Lines := X ......

»ùÓÚXMLµÄÈý²ãC/SÄ£ÐÍ

[ÕªÒª]¿ÉÀ©Õ¹±êÖ¾ÓïÑÔ£¨¼ò³ÆXML£©ÔÚʵÏÖÐÅÏ¢±ê×¼»¯¡¢ÐÅÏ¢µÄ½»Á÷Óë¹²ÏíÉÏÓÐÆä¶ÀÌصļ¼ÊõÓÅÊÆ£¬Òò´ËËüÊܵ½Á˹㷺µÄÖØÊÓ¡£È«ÎÄÊ×ÏÈÌá³öÁË»ùÓÚXMLµÄÈý²ãClient/ServerÄ£ÐÍ£»È»ºó¶ÔÆä´ÓÊý¾Ý»ñÈ¡¡¢´«ÊäÖÁÏÔʾÒÔ¼°Íⲿ´¦ÀíµÄÓ¦ÓýøÐзÖÎö£»½Ó×ÅÒÔͼÊé×ÊÁϹÜÀíϵͳΪÀý£¬ËµÃ÷ÁËÆä¾ßÌåµÄʵÏÖ£»×îºó¶Ô»ùÓÚXMLµÄÈý²ãC/SÄ£ÐÍÔÚÐÅÏ¢±ê×¼» ......

C#СTip£ºXml²Ù×÷¼òÃ÷ÊÖ²á 3

3£©¶ÁÈ¡¡¢²éÕÒ
µ±ÄãÊÖÍ·ÓÐÒ»¸öxmlÎļþºó£¬¿ÉÒÔʹÓÃXmlDocument.Load()·½·¨½«Æä¼ÓÔؽøÀ´ÒԱ㴦Àí£¬ËùÒÔ“¶ÁÈ¡”ûÓÐʲô¿É˵µÄ¡£¶ø“²éÕÒ”²Ù×÷ÍùÍùÉæ¼°XPath£¬ÕâÀïÖ»ÊÇÎÒÈÏΪµÄ±È½Ï³£Óõ½µÄ²éÕÒ²Ù×÷£¬XPathÕâÍæÒâʵÔÚÊǺÜÇ¿´óºÜ±©Á¦¡£
 
»ØÍ·¿´Ê¾ÀýÎĵµxmlsample.xml£¬ÎÒÃÇ¿ÉÄÜÓöµ½ÕâÑùµÄÐèÇó£ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ