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

SAXºÍDOM½âÎöXMLÎĵµµÄÇø±ð

ÔÚÕë¶ÔXMLÎĵµµÄÓ¦Óñà³Ì½Ó¿ÚÖУ¬×îÖ÷ÒªµÄÓÐW3CÖƶ¨µÄDOM(Document Object Method£¬Îĵµ¶ÔÏóÄ£ÐÍ)ºÍÓÉDavid MegginsonÁìµ¼µÄSAX(SimpleAPI for XML£¬ÓÃÓÚXMLµÄ¼òµ¥API)[19]¡£
SAXºÍDOMÔÚʵÏÖ¹ý³ÌÖУ¬·Ö±ð²àÖØÓÚ²»Í¬µÄ·½ÃæÒÔÂú×㲻ͬµÄÓ¦ÓÃÐèÇó¡£DOMΪ¿ª·¢»ùÓÚXMLµÄÓ¦ÓÃϵͳÌṩÁ˱ãÀû¡£Ëüͨ¹ýÒ»ÖÖËæ»ú·ÃÎÊ»úÖÆ£¬Ê¹µÃÓ¦ÓóÌÐòÀûÓøýӿڿÉÒÔÔÚÈκÎʱºò·ÃÎÊXMLÎĵµÖеÄÈκÎÒ»²¿·ÖÊý¾Ý£¬Ò²¿ÉÒÔ¶ÔXMLÎĵµÖеÄÊý¾Ý½øÐвåÈ롢ɾ³ý¡¢Ð޸ġ¢Òƶ¯µÈ²Ù×÷¡£ÔÚDOMÖУ¬ÎĵµµÄÂß¼­½á¹¹ÀàËÆÒ»¿ÃÊ÷¡£Îĵµ¡¢ÎĵµÖеĸù¡¢ÔªËØ¡¢ÔªËØÄÚÈÝ¡¢ÊôÐÔ¡¢ÊôÐÔÖµµÈ¶¼ÊÇÒÔ¶ÔÏóÄ£Ð͵ÄÐÎʽ±íʾµÄ¡£DOMµÄÓŵãÔÚÓÚËüÔÚÄÚ´æÖб£´æÎĵµµÄÕû¸öÄ£ÐÍ¡£ÕâʹµÃÄÜÒÔÈκÎ˳Ðò·ÃÎÊXMLÔªËØ¡£È»¶ø£¬¶ÔÓÚ´óÐÍÎĵµÀ´Ëµ£¬ÕâÑù×ö¿ÉÄܲ»·½±ã¡£ÒòΪËü¿ÉÄÜ»áÓþ¡Äڴ棬»òÕßµ±ÏµÍ³´ïµ½ÁËËüµÄ¼«ÏÞʱ£¬»úÆ÷µÄÐÔÄܽ«
»áÂýÏÂÀ´¡£
SAXÌṩÁËÒ»ÖÖ¶ÔXMLÎĵµ½øÐÐ˳Ðò·ÃÎʵÄģʽ£¬ÕâÊÇÒ»ÖÖ¿ìËÙ¶ÁдXMLÊý¾ÝµÄ·½Ê½¡£SAX½Ó¿ÚÊÇʼþÇý¶¯µÄ£¬µ±Ê¹ÓÃSAX·ÖÎöÆ÷¶ÔXMLÎĵµ½øÐзÖÎöʱ£¬¾Í»á´¥·¢Ò»ÏµÁÐʼþ£¬²¢¼¤»îÏàÓ¦µÄʼþ´¦Àíº¯Êý£¬´Ó¶øÍê³É¶ÔXMLÎĵµµÄ·ÃÎÊ¡£SAX´¦ÀíXMLµÄ·½Ê½ÓëDOM²»Í¬¡£SAX½âÎöÆ÷²»Êǽ«DOMÊ÷½âÎöºÍ±íÏÖΪÊä³ö£¬ËüÊÇ»ùÓÚʼþµÄ£¬ËùÒÔÔÚXML±»½âÎöʱ£¬Ê¼þ±»·¢Ë͸øÒýÇæ¡£SAX¿ÉÒÔÔÚÎĵµµÄ¿ªÊ¼½ÓÊÕʼþ£¬Ò²¿ÉÒÔ½ÓÊÕÎĵµÖеÄÔªËØ¡£Ê¹ÓÃÕâЩʼþ¿ÉÒÔ¹¹½¨Ò»Öֽṹ¡£ÒòΪSAXûÓаÑXMLÎĵµÍêÈ«µØ¼ÓÔص½ÄÚ´æÖУ¬ËùÒÔÐèÒªµÄϵͳ×ÊÔ´½ÏÉÙ£¬ÊÇÒ»¸ö·ÖÎö´óÐÍXMLÎĵµµÄ¸ßЧAPI¡£È±µãÊDZàдSAX±È±àдDOM¸´ÔÓ£¬ÕâÒòΪÊ×ÏȱØÐëʵÏÖ֪ͨ½Ó¿Ú²¢Î¬»¤×´Ì¬£¬Æä´ÎSAX²»ÔÊÐí¶ÔÎĵµ½øÐÐËæ»ú·ÃÎÊ£¬Ò²Ã»ÓÐÌṩÏñDOMÄÇÑùµÄÐ޸ŦÄÜ¡£
±È½Ï¶øÑÔ£¬DOMºÍSAX¸÷ÓÐ×Ô¼ºµÄÓ¦Óó¡ºÏ¡£DOMÊÊÓÃÓÚ´¦ÀíÏÂÃæµÄÎÊÌ⣺½âÎö±È½ÏСµÄXMLÎļþ£»ÐèÒª¶ÔÎĵµ½øÐÐÐ޸ģ»ÐèÒªËæ»ú¶ÔÎĵµ½øÐзÃÎÊ¡£SAXÊÊÓÚ´¦ÀíÏÂÃæµÄÎÊÌ⣺¶Ô´óÐÍÎĵµ½øÐд¦Àí£»Ö»ÐèÒªÎĵµµÄ²¿·ÖÄÚÈÝ£»Ö»ÐèÒª´ÓÎĵµÖеõ½Ìض¨ÐÅÏ¢¡£


Ïà¹ØÎĵµ£º

Linq to XML customize distinct function

Definition comparer class,
class ItemComparer : IEqualityComparer<XElement>
{
public bool Equals(XElement x, XElement y)
{
return x.Attribute("Name").Value == x.Attribute("Name").Value;
}
public int GetHashCode(XElement obj)
......

¡°XML DOM¶ÁÈ¡½ÚµãÐÅÏ¢¡±Ð¡½á

<?
XML DOM¶ÁÈ¡½ÚµãÐÅÏ¢Óöµ½ÎÊÌâ×ܽ᣺  
 
1:NodeList: ʹÓýڵãµÄchildNodesÊôÐÔ»òÕßdocument¶ÔÏóµÄgetElementsByTagName()·½·¨£¬¾Í»á·µ»ØÒ»¸ö°üº¬½ÚµãÁбíµÄNodeList
 
2: ÔÚ XML DOM ÖУ¬½ÚµãµÄ¹Øϵ±»¶¨ÒåΪ½ÚµãµÄÊôÐÔ£º
·  parentNode
·  childNodes
· ......

ÔõôÑùÔÚÍøÒ³É϶ÁÈ¡Ô¶³ÌxmlµÄÊý¾Ý

 ±¾ÎÄת×Ô£ºhttp://www.10086web.com/html/wangluobiancheng/Xmlbiancheng/2009/0612/90.html
Ò»¸ö¿Í»§Ìṩһ¸ö¹É¼ÛµÄÐÅÏ¢£¬ÒªÇó·ÅÔÚÒ³ÃæÉÏ£¬ÏÔʾһЩÊý¾Ý£¬ÐèÒª´ÓÔ¶³Ì»ñÈ¡xml£¬È»ºó½âÎöдÔÚÍøÒ³ÉÏ£¬¿ªÊ¼²»»á¾õµÃºÜÄÑ£¬ÆäʵÂù¼òµ¥µÄ£¬ÏÈÓÃjavascriptдÁËÒ»¸ö£º
<mce:script language=javascript><!--

......

.NET XML ´®Ðл¯½²×ù

1,dz´®Ðл¯£ºÖ»´®Ðл¯ÀàµÄ¹«¹²×ֶκÍÊôÐÔ
    ¹«¹²ÊôÐÔ±ØÐëÊǿɶÁÇÒ¿ÉдµÄ
    Ê¹ÓÃÃüÃû¿Õ¼ä£ºusing System.Xml.Serialization;
    ÒÔBookÀàΪÀý£º
    ´®Ðл¯Ä£°å£º
        public ......

XmlÖÐSelectSingleNode·½·¨ÖеÄxpathÓ÷¨

×î³£¼ûµÄXMLÊý¾ÝÀàÐÍÓУºElement, Attribute£¬Comment, Text.  
 
   Element, Ö¸ÐÎÈç<Name>Tom<Name>µÄ½Úµã¡£Ëü¿ÉÒÔ°üÀ¨£ºElement, Text, Comment, ProcessingInstruction, CDATA, and EntityReference.  
 
   Attribute, Ö¸ÔÚ<Employee >ÖеĴ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ