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

ѧϰ 10 ÖÖÁ¼ºÃµÄ XML ʹÓÃÏ°¹ß(ת)


Martin C. Brown (questions@mcslp.com), ¿ª·¢ÈËÔ±ºÍ×÷¼Ò
2008 Äê 6 ÔÂ 16 ÈÕ
ʹÓñ¾ÎĽéÉÜµÄ 10 ¸ö¼¼Çɸü¼ÓÇáËɵش¦Àí XML£¬´Ó¶ø¼õÉÙ´íÎó²¢Ìá¸ßЧÂÊ¡£
¼ò½é
ÈËÃǶ¼ºÜϲ»¶ XML ÒÔ¼°ËüËùÌṩµÄÁé»îÐԺͻ¥²Ù×÷ÐÔ£¬µ«ÊÇ£¬Í¨¹ýʹÓÃһЩ¼¼ÇÉ£¬¿ÉÒÔʹÓë XML µÄ»¥²Ù×÷ºÍÓë XML Ò»ÆðʹÓõŤ¾ß¸ü¼Ó¼òµ¥¡£ÔÚ´¦Àí XML ʱÑø³ÉһЩÁ¼ºÃµÄÏ°¹ß¿ÉÒÔ±£Ö¤×î¸ßЧµØÀûÓÃÄúµÄ XML ÎĵµºÍÓ¦ÓóÌÐò¡£
 
ʹÓà 10 ÖÖÁ¼ºÃµÄÏ°¹ß
ÒÔÏÂÊÇ 10 ÖÖ×îÁ¼ºÃµÄ XML Ï°¹ß£º
¶¨Òå XML ºÍ±àÂë
ʹÓà DTD »ò XSD
¼ÇµÃ½øÐÐÑéÖ¤
ÑéÖ¤²¢²»×ÜÊÇÄܹ»½â¾öÎÊÌâ
XML ½á¹¹ºÍÊôÐÔ
ʹÓà XPath ²éÕÒÐÅÏ¢
²¢²»×ÜÊÇÐèҪʹÓýâÎöÆ÷ÌáÈ¡ÐÅÏ¢
ºÎʱʹÓà SAX ¶ø·Ç DOM ½âÎö
ºÎʱʹÓà DOM ¶ø·Ç SAX ½âÎö
ʹÓÃÁ¼ºÃµÄ XML ±à¼­Æ÷
 
¾­³£Ê¹ÓõÄËõд´Ê
DOM£ºÎĵµ¶ÔÏóÄ£ÐÍ£¨Document Object Model£©
DTD£ºÎĵµÀàÐͶ¨Ò壨Document Type Definition£©
HTML£º³¬Îı¾±ê¼ÇÓïÑÔ£¨Hypertext Markup Language£©
IDE£º¼¯³É¿ª·¢»·¾³£¨Integrated Development Environment£©
SAX£ºXML ¼òµ¥ API£¨Simple API for XML£©
XSD£ºXML ģʽ¶¨Ò壨XML Schema Definition£©
XML£º¿ÉÀ©Õ¹±ê¼ÇÓïÑÔ£¨Extensible Markup Language£©
XSLT£º¿ÉÀ©Õ¹Ñùʽ±íÓïÑÔת»»£¨Extensible Stylesheet Language Transformations£©
 
 
¶¨Òå XML ºÍ±àÂë
ÔÚ¿ìËÙ´´½¨ XML ÎĵµÊ±£¬Ò»°ã¶¼»áÇãÏòÓÚ´´½¨»ù±¾µÄ½á¹¹²¢±Ü¿ªÒ»Ð©ÆÕͨ XML ÎĵµÐèÇ󣬰üÀ¨Ö¸¶¨ XML ÎĵµÉùÃ÷ºÍ XML Îĵµ°üº¬µÄÊý¾ÝµÄ±àÂëÀàÐÍ¡£
¿¼ÂÇÇåµ¥ 1 ËùʾµÄ XML Îĵµ¡£
Çåµ¥ 1. δ°üº¬ XML ÉùÃ÷ºÍÊý¾Ý±àÂëÀàÐ굀 XML Îĵµ
               
<phrases>
  <phrase lang="en">Hello</phrase>
  <phrase lang="it">Buongiorno</phrase>
  <phrase lang="fr">Salut!</phrase>
</phrases>
 
¶ÔÓÚÆÕͨÈËÀ´Ëµ£¬¿ÉÒԲ鿴¸ÃÎĵµ²¢½«Æäʶ±ðΪ XML£¬µ«ÊǶÔÓÚ¼ÆËã»úÀ´Ëµ£¬ÔòºÜÄÑ×÷³öÕâÑùµÄÅжϡ£ÔÚÎļþ¶¥²¿Ìí¼Ó XML ÉùÃ÷£¬¿ÉÒÔʹËü¸ü¼ÓÃ÷È·¡¢¸üÈÝÒ×ʶ±ð¡£Ò»Ðмòµ¥µÄ´úÂë¾Í¿ÉÒÔ˵Ã÷ÎĵµÊÇ XML£¬²¢ÇÒÖ¸³ö°æ±¾ºÅºÍ XML Êý¾ÝʹÓõÄ×Ö·û±àÂëÀàÐÍ¡£ÀýÈ磺
<?xml version="1.0" encoding="us-ascii"?>
 
±àÂë˵Ã÷ÖеÄÄÚÈÝÒ²Ó¦¸ÃÈ·±£ÕýÈ·ÐÔ¡£XML ½âÎöÆ÷ʹÓñàÂëÈ·±£ XML Îĵµµ


Ïà¹ØÎĵµ£º

°ÑXMLDocumentת»»³Éxml×Ö·û´®

XMLDocumentÀàÌṩÁ˷ḻµÄÊôÐԺͷ½·¨£¬¿ÉÒÔ°ïÖúÎÒÃÇÇáËÉÍê³ÉxmlµÄ±à¼­¡£µ«ÊÇ£¬Íê³ÉºóµÄxmlºÜ¶àÇé¿öÏ¿ÉÄÜ»¹ÊÇÐèÒªÒÔ×Ö·û´®ÐÎʽ´«µÝ¡£XMLDocumentÓиöSave·½·¨£¬²»½ö¿ÉÒÔ±£´æXMLÎļþÖÁ´ÅÅÌ£¬»¹Äܽ«Æä±£´æÖÁÖ¸¶¨µÄÁ÷£¬È»ºó£¬¾ÍÄÜ´ÓÕâ¸öÁ÷£¨stream£©¶ÁÈ¡ËùÐèÒªµÄ×Ö·û´®ÁË¡£
XmlDocument doc = new XmlDocument();
...
.../ ......

¶ÁxmlÎļþ


ÍøÉÏÌṩµÄһЩ·½·¨±È½Ï¼òµ¥£¬ÎÞ·¨ÊÊÓ¦XMLÎļþµÄ¶¯Ì¬±ä»¯ £¬Ã»°ì·¨Ö»ÄÜ×Ô¼º²éÎĵµÐ´£¬×ÜËãûÀË·Ñʱ¼ä£¬ÓõÄʱºò±ðÍüÁ˼Ó#import
"msxml4.dll"Õâ¸ö¶¯Ì¬Á´½Ó¿âÍøÉϺܺÃÕÒ£¬×Ô¼ºÕÒһϣ¬Ï£ÍûÄÜ°ïÖúÐèÒªµÄÅóÓÑ£¬À§ÁË
::CoInitialize(NULL);
//³õʼ»¯COM
 MSXML2::IXMLDOMDocumentPtr pDoc;
  ......

Google XML Sitemaps×ÜÊÇÌáʾÎÞȨÏÞ£¿


ÔÚʹÓÃGoddadyÖ÷»úʹÓÃ
Google XML
Sitemaps²å¼þµÄʱºò£¬×ÜÌáʾÎÞȨÏÞ£¬¶øʵ¼ÊÉÏÎÒÊÇÁËȨÏ޵ģ¬°Ñ²å¼þÏÂÔص½±¾µØ£¬Ò²ÊÇ¿ÉÒÔÕý³£Éú³ÉsitemapµÄ£¬Ôõô°ì£¿×ÔÈ»²»ÄÜÄѵ¹ÔÛ
Iter¡£
¼ìË÷¶à·½¼ì²é£¬·¢ÏÖÔÚ·þÎñÆ÷ÉÏ£¬¼ì²é·¾¶Ò»ÏîΪsitemap.xml£¬¶øÔÚ±¾µØ£¬¼ì²é·¾¶
Ϊd:\workstation\site\iove.net\sitemap.xml£¬Ò²¾ÍÊÇ˵ ......

xml´¦Àí

JAXBContext jc = JAXBContext.newInstance(ICPBuildSummaryXO.class);
   Unmarshaller u = jc.createUnmarshaller();
   ICPBuildSummaryXO xo = (ICPBuildSummaryXO) u.unmarshal(node);
   ICPBuildSummary summary = new ICPBuildSummary();
   Bean ......

C#»ñÈ¡XMLÎļþÖ¸¶¨½ÚµãµÄÊý¾Ý

ʵÀý˵Ã÷»á¸üÇå³þЩ£¬¼ÙÉèÓÐÈçÏÂXMLÎļþ£º
¡¡File: message_hutaow.xml
<?xml version="1.0" encoding="UTF-8"?>
<hutaow:Message version="1.0" xmlns:hutaow="http://wangtao.cublog.cn">
<hutaow:Head>
<hutaow:Date>20080502</hutaow:Date>
<hutaow:Source>
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ