XMLÎļþѧϰ
XML CDATA Îı¾
ËùÓÐ XML ÎĵµÖеÄÎı¾¾ù»á±»½âÎöÆ÷½âÎö¡£
Ö»ÓÐ CDATA Çø¶Î£¨CDATA section£©ÖеÄÎı¾»á±»½âÎöÆ÷ºöÂÔ¡£
Parsed Data
XML ½âÎöÆ÷ͨ³£»á½âÎö XML ÎĵµÖÐËùÓеÄÎı¾¡£
µ±Ä³¸ö XML ÔªËر»½âÎöʱ£¬Æä±êÇ©Ö®¼äµÄÎı¾Ò²»á±»½âÎö£º
<message>´ËÎı¾Ò²»á±»½âÎö</message>
½âÎöÆ÷Ö®ËùÒÔÕâô×öÊÇÒòΪ XML ÔªËØ¿É°üº¬ÆäËûÔªËØ£¬¾ÍÏñÕâ¸öÀý×ÓÖУ¬ÆäÖÐµÄ <name> ÔªËØ°üº¬×ÅÁíÍâµÄÁ½¸öÔªËØ(first ºÍ last)£º
<name><first>Bill</first><last>Gates</last></name>
¶ø½âÎöÆ÷»á°ÑËü·Ö½âΪÏñÕâÑùµÄ×ÓÔªËØ£º
<name>
<first>Bill</first>
<last>Gates</last>
</name>
תÒå×Ö·û·Ç·¨µÄ XML ×Ö·û±ØÐë±»Ì滻ΪʵÌåÒýÓã¨entity reference£©¡£¼ÙÈçÄúÔÚ XML ÎĵµÖзÅÖÃÁËÒ»¸öÀàËÆ "<" ×Ö·û£¬ÄÇôÕâ¸öÎĵµ»á²úÉúÒ»¸ö´íÎó£¬ÕâÊÇÒòΪ½âÎöÆ÷»á°ÑËü½âÊÍΪÐÂÔªËصĿªÊ¼¡£Òò´ËÄã²»ÄÜÕâÑùд£º<message>if salary < 1000 then</message>
ΪÁ˱ÜÃâ´ËÀà´íÎó£¬ÐèÒª°Ñ×Ö·û "<" Ì滻ΪʵÌåÒýÓ㬾ÍÏñÕâÑù£º
<message>if salary < 1000 then</message>
ÔÚ XML ÖÐÓÐ 5 ¸öÔ¤¶¨ÒåµÄʵÌåÒýÓãº
<
<
СÓÚ
>
>
´óÓÚ
&
&
ºÍºÅ
'
'
Ê¡ÂÔºÅ
"
"
ÒýºÅ
×¢ÊÍ£ºÑϸñµØ½²£¬ÔÚ XML ÖнöÓÐ×Ö·û "<"ºÍ"&" ÊÇ·Ç·¨µÄ¡£Ê¡ÂԺš¢ÒýºÅºÍ´óÓÚºÅÊǺϷ¨µÄ£¬µ«ÊÇ°ÑËüÃÇÌ滻ΪʵÌåÒýÓÃÊǸöºÃµÄÏ°¹ß¡£
CDATA
CDATA ÄÚ²¿µÄËùÓж«Î÷¶¼»á±»½âÎöÆ÷ºöÂÔ¡£
¼ÙÈçÎı¾Öаüº¬ÁË´óÁ¿µÄ "<" ºÍ "&" ×Ö·û - ¾ÍÏñ±à³Ì´úÂëÖо³£³öÏÖµÄÇé¿öÒ»Ñù - ÄÇôÕâ¸ö XML ÔªËؾͿÉÒÔ±»¶¨ÒåΪһ¸ö CDATA ²¿·Ö¡£
CDATA Çø¶Î¿ªÊ¼ÓÚ "<![CDATA["£¬½áÊøÓÚ "]]>"£º
<script>
<![CDATA[
function matchwo(a,b)
{
if (a < b && a < 0)
{
return 1
}
else
{
return 0
}
}
]]>
</script>
ÔÚÉÏÃæµÄÀý×ÓÖУ¬ÔÚ CDATA Çø¶ÎÖеÄËùÓж«Î÷¶¼»á±»½âÎöÆ÷ºöÂÔ¡£
¹ØÓÚ CDATA Çø¶ÎµÄ×¢ÊÍ£º
CDATA Çø¶Î²»ÄÜ°üº¬×Ö·û´® "]]>"£¬ËùÒÔ£¬CDATA Çø¶ÎµÄǶÌ×ÊDz»±»ÔÊÐíµÄ¡£
ͬʱҲÐèҪȷ±£ÔÚ "]]>" ×Ö·û´®ÖÐûÓпոñ»òÕÛÐС£
Ïà¹ØÎĵµ£º
´ËXMLʵÀýÒÔ·þÎñÆ÷¶Ë²¿ÃŹÜÀíΪÀý£º£¨Æä½çÃæÈçÏ£©
private void btn_UpdateGroup_Click(object sender, EventArgs e)
{
XmlDocument xmlDoc = new XmlDocument();
& ......
1.Èç¹ûÐèÒªÔÚÓ¦ÓóÌÐòÖд¦ÀíxmlÊý¾Ý£¬Ê×ÏÈÒª´´½¨1¸öXmlDocument¶ÔÏó£¬È»ºóͨ¹ýload·½·¨´ÓxmlÊý¾ÝÔ´ÖмÓÔضÔÏó¡£
2.xmlÖеÄÊý¾ÝÖ÷Òª±íÏÖΪԪËغÍÊôÐÔÁ½ÖÖÐÎʽ¡£
3.¶ÁÈ¡ÔªËØ
¶ÁÈ¡ÔªËØ¿Éͨ¹ýij½ÚµãµÄChildNodesÊôÐÔ»ñÈ¡Æä×ӽڵ㼯ºÏ£¬È»ºó¸ù¾Ý½ÚµãµÄNodeTypeÊôÐÔÈ·¶¨´Ë½ÚµãÊÇ·ñÊôÓÚÔªËؽڵ㡣ԪËؽڵãµÄÃû³Æ¿Éͨ¹ýNameÊôÐÔ» ......
Ç°ÑÔ
XMLÔ½À´Ô½ÈÈ£¬¹ØÓÚXMLµÄ»ù´¡½Ì³ÌÍøÂçÉ ......
×÷Õߣºwuhua
¿Õ¼ä£ºhtt://wuhua.3geye.net
תÔØÇë±£ÁôÉÏÃæµÄÐÅÏ¢£¨Çë×ðÖØ֪ʶ²úÆ·£©Ð»Ð»
ÏàÐÅ´ó¼Ò¶¼ÓùýKxmlµÄ¶«Î÷ÁË£¬²»¹ý¸öÈ˸оõkxml»¹ÊÇ´óÁËЩ¡£ÏÖÔÚ½éÉÜÒ»¸ö±Èkxml¸ú¼ò½éµÄxmlµÄÀà¡£¶ÔÓÚһЩСÏîÄ¿£¬»òÕ߶Ôxml½âÊÍÒªÇó²»ÊǺܸߵÄÏîÄ¿À´ËµÈ´ÊǸö²»´íµÄÑ¡Ôñ¡£
ÏÂÃæ¿´¿´ÄÇ´úÂëÓëDemo°É¡£
Java´úÂë
package o ......
н¨xmlÎļþµÄÇé¿ö¿ÉÄܲ»¶à£¬µ«¶Ô½Úµã¡¢ÊôÐÔµÄÔöɾ¸Ä²é»áºÜ³£¼û
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Server.MapPath("data.xml"));
ÕâÁ½¾äÓ¦¸ÃºÜ³£Óõģ¬¼ÓÔØÒѾ´æÔÚµÄxmlÎĵµ¡£
XmlNode root;//¸ù½Úµã
root = xmldoc.DocumentElement;//»ñÈ¡¸ù½ ......