Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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£©±£´


Ïà¹ØÎĵµ£º

XML³£ÓòÙ×÷

 XMLÔÚÎÒÃǵijÌÐòÖÐÓõ½µÄÔ½À´Ô½¶à£¬ÒòΪËü´æ´¢¡¢¶ÁÈ¡¡¢Ð޸Ķ¼±È½Ï·½±ã¡£
ÏÂÃæÎÒÀ´·ÖÏíÒ»ÏÂXMLµÄ³£ÓòÙ×÷(Ôöɾ¸Ä²é)£¬ÏÂÃæÊdzÌÐòÔËÐÐЧ¹û£º
Ôö(Ôö¼Ó½Úµã°üÀ¨´´½¨XML):
/// <summary>
/// ´´½¨XMLÎĵµ
/// </summary>
/// <param name="path"></param>
......

PHP+DOM´´½¨XMLÎļþ

´´½¨ÎĵµÀàÐÍÉùÃ÷
Ò»°ã¶øÑÔ£¬XMLÉùÃ÷·ÅÔÚÎĵµ¶¥²¿¡£ÔÚPHPÖÐÉùÃ÷Ê®·Ö¼òµ¥£ºÖ»ÐèʵÀý»¯Ò»¸öDOMÎĵµÀàµÄ¶ÔÏ󲢸³ÓèËüÒ»¸ö°æ±¾ºÅ¡£²é¿´³ÌÐòÇåµ¥A£º
³ÌÐòÇåµ¥ A
<?php
// create doctype
$dom = new DOMDocument("1.0");
// display document in browser as plain text
// display document in browser as plain text ......

XML×Ö·û´®ºÍXMLÎĵµÖ®¼äµÄ×ÔÓÉת»»

±¾ÎÄϵתÔØ£¬½÷ÏòתÔØ´¦¿Õ¼äÓµÓÐÕß¼°Ô´³ö´¦ÎÄÕÂ×÷Õß±íʾ¸Ðл£¡
תÔØ´¦£ºhttp://henry19890701.javaeye.com/blog/481462
Ô´³ö´¦£ºhttp://www.ziliaonet.com/tech/netprogramme/XML/200605/69398.html
ÔÚ×öÒ»°ãµÄXMLÊý¾Ý½»»»¹ý³ÌÖУ¬ÎÒ¸üÀÖÒâ´«µÝXML×Ö·û´®£¬¶ø²»ÊǸñʽ»¯µÄXML Document¡£Õâ¾ÍÉæ¼°µ½XML×Ö·û´®ºÍXml Docume ......

javascript²Ù×÷xmlÉú³ÉÊ÷Ðβ˵¥


Õâ¸öЧ¹ûÓ¦¸Ã²»ËãʲôϡÆ棬ÍøÉÏÒ²ÓÐÏֳɵĴúÂ룬ÎÒÕâ¸öҲûʲôÌرðµÄµØ·½£¬Ö»ÊÇÒòΪÎÒ×Ô¼ºÐ´µÄ£¬Ò²ËãÊÇΪѧϰDOMºóÒ»¸öÁ·Ï°£»ÔÚIEϲâÊÔͨ¹ý£»
ʵÏÖЧ¹ûÊÇÕâÑùµÄ£º
¶ÁÈ¡XMLÎĵµ£»
²ÉÓõݹéÉú³ÉÎÞÏÞ¼¶µÄÊ÷Ðβ˵¥£»
Äܹ»ÏìÓ¦Êó±êʼþ£¬Õ¹¿ªÓë²ðµþ×Ó¼¶²Ëµ¥£»
Ê×ÏÈÊÇÉú³ÉÒ»¸öXMLÎĵµ£¬ÎÒÓõÄÊÇXML SpyµÄ±à¼­Æ÷£»
< ......

XML·Ö½âʵÀý

Ô­Ìù: http://topic.csdn.net/u/20100414/11/c69748ac-e0b2-490f-bde9-7c5284c3660c.html?seed=1832202493
 
declare @xml xml=
'<upd:Update xmlns:lar="http://schemas.microsoft.com/msus/2002/12/LogicalApplicabilityRules" xmlns:cmd="http://schemas.microsoft.com/msus/2002/12/UpdateHandlers/Command ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ