XML DOM½éÉÜ
ÐÄÓêÖ®¼Ò web¿ª·¢
XML DOM½éÉÜ
Ò»¡¢XML DOM¼ò½é
DOM£¨Document Object Model£¬Îĵµ¶ÔÏóÄ£ÐÍ£©ÊÇÒ»ÖÖÓ¦ÓóÌÐò½Ó¿Ú£¨API£©µÄÓ¦Óã¬Ëü½«Îĵµ£¨ÈçXMLÎĵµ£¬HTMLÎĵµµÈ£©¿´³ÉÊÇÒ»¸öÎĵµ¶ÔÏó£¬È»ºóͨ¹ý³ÌÐòÓïÑÔ£¨ÈçJavaScriptµÈ½Å±¾ÓïÑÔ£¬C++µÈ£©µ÷ÓøÃÎĵµ¶ÔÏ󣬶ÔÎĵµÖеÄÊý¾Ý½øÐдæÈ¡£¬²¢ÀûÓóÌÐò¶Ô»ñÈ¡µÄÊý¾Ý½øÐиú½øÒ»²½µÄ´¦Àí¡£
XML DOMÊǽ«XMLÎĵµÒÔDOM·½Ê½°ü×°£¬Í¨¹ýDOM¼¼Êõ£¬Ó¦ÓóÌÐò¼´¿ÉºÜÈÝÒ×µØÌáÈ¡XMLÎĵµÖеÄÊý¾Ý¡£
¶þ¡¢XML DOM¶ÔÏó
IEʵÏÖÁ˶ÔXML DOM¼¼ÊõµÄÖ§³Ö£¬ÌṩÁËÎå¸ö¿ÉÒÔÔڽű¾³ÌÐòÖе÷ÓõÄXML DOM¶ÔÏó£º
£¨1£© XMLDOMDocument
¸Ã¶ÔÏó´ú±íÕû¸öXMLÎĵµ£¬Ëü¾ßÓжàÖÖÊôÐԺͷ½·¨À´»ñÈ¡»ò´´½¨ÆäËûXML DOM¶ÔÏó¡£
£¨2£© XMLDOMNode
¸Ã¶ÔÏó¿ÉÒÔ´ú±íXMLÎĵµµÄ¸ùÔªËØÒÔ¼°¸ùÔªËØϵĸ÷¸ö½Úµã¡£ËüÖ§³ÖÊý¾ÝÀàÐÍ¡¢ÃûÓò¡¢DTDºÍSchema£¬²¢ÇÒÒÔ´ËÀ©Õ¹ºËÐĵÄXML DOM½Úµã½Ó¿Ú¡£
£¨3£© XMLDOMNodeList
¸Ã¶ÔÏó´ú±íXMLÎĵµÖÐһϵÁнڵã×é³ÉµÄÒ»¸ö½ÚµãÁÐ±í£¬²¢ÇÒÖ§³Ö¶Ô¸ÃÁбíµÄ±éÀú¡£
£¨4£© XMLDOMNamedNodeMap
¸Ã¶ÔÏóÖ§³ÖÃûÓòºÍ¶ÔÊôÐÔ¼¯µÄ±éÀú¡£
£¨5£© XMLDOMParseError
¸Ã¶ÔÏóÓÃÓÚ·µ»Ø×î½üÒ»´Î½âÎö´íÎóµÄÏêϸÐÅÏ¢£¬°üÀ¨´íÎóºÅ¡¢´íÎóËùÔÚÐС¢´íÎóËùÔÚ×Ö·ûλÖÃÒÔ¼°¶Ô´íÎóµÄÒ»¸öÃèÊöÎı¾¡£
Èý¡¢XML DOMÊôÐÔ
XML DOMÎĵµµÄ±éÀúÓëHTML DOMµÄ±éÀú·Ç³£ÀàËÆ£¬ÒòΪËüÃǶ¼Êǽڵã²ã´ÎµÄ½á¹¹¡£½ÚµãÊ÷µÄ×²¿ÊÇdocumentElementÊôÐÔ£¬°üº¬ÎĵµµÄ¸ùÔªËØ¡£Ê¹ÓÃϱíÖÐËùÁгöµÄÊôÐÔ£¬¿ÉÒÔ·ÃÎÊÎĵµÖÐÈκÎÔªËØ»òÊôÐÔ¡£
±í4-1 XML DOMÊôÐÔ
Êô ÐÔ
Ãè Êö
attributes
°üº¬µ±Ç°½ÚµãÊôÐÔµÄÊý×é
childNodes
°üº¬×Ó½ÚµãÊý×é
firstChild
Ö¸Ïòµ±Ç°½ÚµãµÄµÚÒ»¸ö×Ó½Úµã
lastChild
Ö¸Ïòµ±Ç°½ÚµãµÄ×îºóÒ»¸ö×Ó½Úµã
nextSibling
·µ»Øµ±Ç
Ïà¹ØÎĵµ£º
Ñо¿E4XÓëFlexµÄ¹Øϵ£¬ËùÒÔ´òËã×ܽáһϣ¬ÓÐ˵µÄ²»¶ÔµÄµØ·½£¬»¹Çë´ó¼Ò¶à¶àÔÁ¡£
Ò»¡¢×î¼òµ¥Ä£Ê½£ºFlexͨ¹ýhttpserviceºÍdataProvider½øÐÐÊý¾Ý´«Êä
Xml¸ñʽÈçÏ£º
<?xml version="1.0" encoding="utf-8" ?>
<Result>
<NodeA>value1</NodeA>
<NodeB>valve2</NodeB>
…&he ......
ÔÚJ2MEÌåϵÖУ¬¶ÔxmlµÄ½âÎöÓбȽÏÓÐÃûµÄµÚÈý·½½âÎöAPI£¬·Ö±ðΪKXMLºÍNanoXML£¬ËûÃǶ¼ÌṩÁ˶ԽâÎöxmlµÄÖ§³Ö¡£KXMLÔÚ½âÎöXML¹ý³ÌÖлá¶ÔÎļþÄÚÈÝÒ»²ãÒ»²ã½øÐнâÎö£¬Òò´Ë³ÉΪÔöÁ¿Ê½½âÎöÆ÷£¬±È½ÏÊʺϴóÎļþµÄ½âÎö¡£¶øNanoXMLÊÇÒ»´ÎÐÔ½âÎöÆ÷£¬ÔÚÒ»´Îʱ¼äÀï¾Í°ÑÕû¸öxmlÎĵµ½âÎöÍ꣬Òò´Ë²»ÊʺϴóÎļþµÄ½âÎö£¬»áÔì³ÉÄÚ´æ²»×ãµÄÏÖÏó¡ ......
<?xml version="1.0" encoding="UTF-8"?>
<company>
<tel>020-12345678-66</tel>
<tel>020-12345678-85</tel>
<introduce>
<![CDATA[
<br/><h1>¹«Ë¾¼ò½é& ......
±éÀúXMLÎĵµ
¶ÔÓÚÏÂÃæµÄÒ»¶ÎXML´úÂ룺
XMLÎĵµÊµÀýbooks.xml£¬ÈçÏÂËùʾ£º
<?xml version="1.0" encoding="gb2312" ?>
<books>
<book status="ÒÑÊÛÍê">
<author>ÆÆÆÆ</author>
<title>XMLÈëÃÅ</title >
</book>
<book statu ......
XMLÎļþ×÷ΪÊý¾ÝÊý¾Ý´æ´¢½éÖʵÄÒ»ÖÖ£¬ºÃ´¦ÔÚÓÚ£ºÈκεÄϵͳ¾ù¿ÉÒÔ½âÎöËü¡£
XMLÈ«³Æ£ºExtensible Markup Language£¨À©Õ¹±ê¼ÇÓïÑÔ£©Ê¹ÓÃÎĵµÀàÐͶ¨Ò壨DTD£©»òÕßģʽ£¨Schema£©À´ÃèÊöÊý¾ÝµÄ¡£¿É¹©ÈËÔĶÁ£¬¶øÇÒ»¹»ùÓÚÒ»ÖÖ¹«¹²µÄ¿ª·¢±ê×¼¡£
×î½üÓÉÓÚ¿ª·¢µÄÐèÒª£¬Ò²ÊÇÑо¿ÒÔÏÂXMLµÄ²Ù×÷£¬±¾ÆªÈÕÖ¾Ö÷Òª×ܽáC#.NETÖÐÊÇÈçºÎ²Ù×÷XM ......