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

jdom¶ÁÈ¡xmlÎļþ


import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;
£¨1£©Ê¹ÓÃJDOMÊ×ÏÈÒªÖ¸¶¨Ê¹ÓÃʲô½âÎöÆ÷¡£È磺
          SAXBuilder builder=new SAXBuilder(false); Õâ±íʾʹÓõÄÊÇĬÈϵĽâÎöÆ÷
£¨2£©µÃµ½Document£¬ÎÒÃÇÒÔºóÒª½øÐеÄËùÓвÙ×÷¶¼ÊǶÔÕâ¸öDocument²Ù×÷µÄ£º
          Document
doc=builder.build(xmlpath);
£¨3£©µÃµ½¸ùÔªËØ£º
          Element
books=doc.getRootElement();
ÔÚJDOMÖÐËùÓеĽڵ㣨DOMÖеĸÅÄ¶¼ÊÇÒ»¸öorg.jdom.ElementÀ࣬µ±È»ËûµÄ×Ó½ÚµãÒ²ÊÇÒ»¸öorg.jdom.ElementÀà¡£
£¨4£©µÃµ½ÔªËØ£¨½Úµã£©µÄ¼¯ºÏ£º
        List booklist=books.getChildren("book");
Õâ±íʾµÃµ½“books”ÔªËØµÄËùÔÚÃû³ÆÎª“book”µÄÔªËØ£¬²¢°ÑÕâÐ©ÔªËØ¶¼·Åµ½Ò»¸öList¼¯ºÏÖÐ
£¨5£©ÂÖÑ­List¼¯ºÏ
       for (Iterator iter = booklist.iterator();
iter.hasNext();) {
         Element book = (Element)
iter.next();
      £ý
»¹ÓÐÒ»ÖÖÂÖÑ­·½·¨ÊÇ£º
      for(int i=0;I<booklist.size();I++){
        Element
book=(Element)booklist.get(i);
      }
£¨6£©È¡µÃÔªËØµÄÊôÐÔ£º
      String
email=book.getAttributeValue("email");
     È¡µÃÔªËØbookµÄÊôÐÔÃûΪ“email”µÄÊôÐÔÖµ¡£
£¨7£©È¡µÃÔªËØµÄ×ÓÔªËØ£¨Îª×îµÍ²ãÔªËØ£©µÄÖµ£º
      String
name=book.getChildTextTrim("name");
      ×¢ÒâµÄÊÇ£¬±ØÐëÈ·¶¨bookÔªËØµÄÃûΪ“name”µÄ×ÓÔªËØÖ»ÓÐÒ»¸ö¡£
£¨8£©¸Ä±äÔªËØ£¨Îª×îµÍ²ãÔªËØ£©µÄÖµ£º
     
book.getChild("name").setText("alterrjzjh");
      ÕâÖ»ÊǶÔDocumentµÄÐ޸쬲¢Ã»ÓÐÔÚʵ¼ÊµÄXMLÎĵµÖнøÐÐÐÞ¸Ä
£¨9£©±£´


Ïà¹ØÎĵµ£º

.net ²Ù×÷XMLС½á

Ò»¡¢¼òµ¥½éÉÜ
using System.Xml;
//³õʼ»¯Ò»¸öxmlʵÀý
XmlDocument xml=new XmlDocument();
//µ¼ÈëÖ¸¶¨xmlÎļþ
xml.Load(path);
xml.Load(HttpContext.Current.Server.MapPath("~/file/bookstore.xml"));
//Ö¸¶¨Ò»¸ö½Úµã
XmlNode root=xml.SelectSingleNode("/root");
//»ñÈ¡½ÚµãÏÂËùÓÐÖ±½Ó×Ó½Úµã
XmlNodeList ch ......

Perl½âÎöXMLÎļþʱµÄ×Ö·û¼¯±àÂëÎÊÌâ

http://stackoverflow.com/questions/1112828/cannot-decode-string-with-wide-characters-appears-on-a-weird-place
http://man.ddvip.com/web/xmlzhzn/xml_cn/xml_encoding.asp.htm
http://bbs.xml.org.cn/dispbbs.asp?boardID=8&ID=7226
http://topic.csdn.net/t/20030909/13/2240153.html
#
http://www.ezloo. ......

Spring XMLÅäÖõÄ12¸ö¼¼ÇÉ

 
1 ÔÚActionʵÏÖÀà·½ÃæµÄ¶Ô±È£ºStruts 1ÒªÇóActionÀà¼Ì³ÐÒ»¸ö³éÏó»ùÀࣻStruts 1µÄÒ»¸ö¾ßÌåÎÊÌâÊÇʹÓóéÏóÀà±à³Ì¶ø²»Êǽӿڡ£Struts 2 ActionÀà¿ÉÒÔʵÏÖÒ»¸öAction½Ó¿Ú£¬Ò²¿ÉÒÔʵÏÖÆäËû½Ó¿Ú£¬Ê¹¿ÉÑ¡ºÍ¶¨ÖƵķþÎñ³ÉΪ¿ÉÄÜ¡£Struts 2Ìṩһ¸öActionSupport»ùÀàȥʵÏÖ³£ÓõĽӿڡ£¼´Ê¹Action½Ó¿Ú²»ÊDZØÐëʵÏֵģ¬Ö»ÓÐÒ» ......

C# XmlÖÐÓ³ÉäΪÀàÊý¾Ý½á¹¹£¨±¨ÎÄ£©

        [System.Runtime.Serialization.DataMemberAttribute()]
        public Information Archive {
            get {
         &n ......

XMLÎļþ°ó¶¨Êý¾Ý¼¯¿Ø¼þ²Ù×÷

//Êý¾Ý°ó¶¨
    public void DataBind()
    {
        DataSet ds = new DataSet();
        ds.ReadXml(Server.MapPath(@"App_data/dbGuest.xml"));
&nbs ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ