XMLÎļþµÄ½âÎö££libxml¿âº¯Êý½âÊÍ
XMLÎļþµÄ½âÎö££libxml¿âº¯Êý½âÊÍ[ת]
libxml£¨Ò»£©
ÕªÒª
LibxmlÊÇÒ»¸öÓÐÃâ·ÑÐí¿ÉµÄÓÃÓÚ´¦ÀíXML¡¢¿ÉÒÔÇáËÉ¿çÔ½¶à¸öƽ̨µÄCÓïÑÔ¿â¡£Õâ¸öÖ¸ÄÏÌṩËüµÄ»ù±¾º¯ÊýµÄÀý×Ó¡£
Ð÷ÂÛ
LibxmlÊÇÒ»¸öʵÏÖ¶Á¡¢´´½¨¼°²Ù×ÝXMLÊý¾Ý¹¦ÄܵÄCÓïÑÔ¿â¡£Õâ¸öÖ¸ÄÏÌṩÀý×Ó´úÂë²¢¸ø³öËü»ù±¾¹¦ÄܵĽâÊÍ¡£ÔÚÕâ¸öÏîÄ¿µÄÖ÷Ò³ÉÏÓÐLibxml¼°¸ü¶à¹ØÓÚËü¿ÉÓõÄ×ÊÁÏ¡£°üº¬ÓÐÍêÕûµÄAPIÎĵµ¡£Õâ¸öÖ¸Äϲ¢²»ÄÜÌæ´úÕâЩÍêÕûµÄÎĵµ£¬µ«ÊDzûÃ÷¹¦ÄÜÐèҪʹÓÿâÀ´Íê³É»ù±¾²Ù×÷¡£
Õâ¸öÖ¸ÄÏ»ùÓÚÒ»¸ö¼òµ¥µÄXMLÓ¦Óã¬ËüʹÓÃÎÒдµÄһƪÎÄÕÂÉú³É£¬Ëü°üº¬ÓÐÔªÊý¾ÝºÍÎÄÕµÄÖ÷Ìå¡£
±¾Ö¸ÄÏÖеÄÀý×Ó´úÂëʾ·¶ÈçºÎ×öµ½£º
• ½âÎöÎĵµ
• È¡µÃÖ¸¶¨ÔªËصÄÎı¾
• Ìí¼ÓÒ»¸öÔªËؼ°ËüµÄÄÚÈÝ
• Ìí¼ÓÒ»¸öÊôÐÔ
• È¡µÃÒ»¸öÊôÐÔµÄÖµ
Àý×ÓµÄÍêÕû´úÂë°üº¬ÔÚ¸½Â¼ÖÐ
Êý¾ÝÀàÐÍ
Libxml¶¨ÒåÁËÐí¶àÊý¾ÝÀàÐÍ£¬ÎÒÃǽ«·´¸´Åöµ½ËüÃÇ£¬ËüÒþ²ØÁËÔÓÂÒµÄÀ´Ô´ÒÔÖÂÄã²»±Ø´¦ÀíËü³ý·ÇÄãÓÐÌض¨µÄÐèÒª¡£xmlChar Ìæ´úchar,ʹÓÃUTF-8±àÂëµÄÒ»×Ö½Ú×Ö·û´®¡£Èç¹ûÄãµÄÊý¾ÝʹÓÃÆäËü±àÂ룬Ëü±ØÐ뱻ת»»µ½UTF-8²ÅÄÜʹÓÃlibxmlµÄº¯Êý¡£ÔÚlibxml±àÂëÖ§³ÖWEBÒ³ÃæÓиü¶à¹ØÓÚ±àÂëµÄÓÐÓÃÐÅÏ¢¡£
XmlDoc °üº¬ÓɽâÎöÎĵµ½¨Á¢µÄÊ÷½á¹¹£¬xmlDocPtrÊÇÖ¸ÏòÕâ¸ö½á¹¹µÄÖ¸Õë¡£
xmlNodePtr and xmlNode °üº¬µ¥Ò»½áµãµÄ½á¹¹xmlNodePtrÊÇÖ¸ÏòÕâ¸ö½á¹¹µÄÖ¸Õ룬Ëü±»ÓÃÓÚ±éÀúÎĵµÊ÷¡£
½âÎöÎĵµ
½âÎöÎĵµÊ±½ö½öÐèÒªÎļþÃû²¢Ö»µ÷ÓÃÒ»¸öº¯Êý£¬²¢ÓдíÎó¼ì²é¡£ÍêÕû´úÂ룺¸½Â¼C, KeywordÀý³Ì´úÂë
¢ÙxmlDocPtr doc;
¢ÚxmlNodePtr cur;
¢Ûdoc = xmlParseFile(docname);
¢Üif (doc == NULL ) {
fprintf(stderr,"Document not parsed successfully. \n");
return;
}
¢Ýcur = xmlDocGetRootElement(doc);
¢Þif (cur == NULL) {
fprintf(stderr,"empty document\n");
xmlFreeDoc(doc);
return;
}
¢ßif (xmlStrcmp(cur->name, (const xmlChar *) "story")) {
fprintf(stderr,"document of the wrong type, root node != story");
xmlFreeDoc(doc);
return;
}
¢Ù¶¨Òå½âÎöÎĵµÖ¸Õë¡£
¢Ú¶¨Òå½áµ
Ïà¹ØÎĵµ£º
XMLÐòÁл¯Óë·´ÐòÁл¯ ÕûÀíÎĵµ
XMLÐòÁл¯Óë·´ÐòÁл¯
// OBJECT -> XML
public static void SaveXml(string filePath, object obj) { SaveXml(filePath, obj, obj.GetType()); }
public static void SaveXml(string filePath, object obj, System.Type ty ......
Ç°¶Îʱ¼äÓÃjQuery×öÁ˸öСÁ·Ï°£¬»ñÈ¡±¾µØµÄxmlÊý¾Ý£¬ÔÚfirefoxÏÂÃæ²âÊÔûÎÊÌ⣬µ«ÊÇÔÚIEÏÂÃæ×ÜÊÇ»ñÈ¡Êý¾Ýʧ°Ü£¬ÉÏÍøÕÒÁ˺ܾÃҲûÕÒµ½ÊÇÔõô»ØÊ¡£ÓôÃÆÁ˺ܳ¤Ò»¶Îʱ¼ä£¬½ñÌìÓпÕÓÖ°ÑÕâ¸öÎÊÌâÄóöÀ´Ñо¿ÁËÏ£¬×îºóÖÕÓÚÕÒµ½ÔÒòÁË£¬°ÑÒ³Ãæ·Åµ½·þÎñÆ÷È¥ä¯ÀÀ¾ÍOKÁË¡£ÄѵÀÊÇȨÏÞÎÊÌ⣿²»ÖªµÀÔõô»ðºüÔÚ±¾µØĿ¼¿ÉÒÔ»ñÈ¡Êý¾Ý³É¹¦¡£ ......
Ò»¡¢²âÊÔÓõÄem.xml
<?xml version="1.0" encoding="GB2312"?>
<EW cmd="login" mod="Login" version="6.0">
<Source uns="" type="user"/>
<Username>zhangzhiyun@hp</Username>
<Password>111111</Password> ......
¹¤×÷ÖÐÓöµ½ÐèÒªºÏ²¢XMLµÄÎÊÌ⣬Ëì´ÓÍøÉϲéÕÒÏà¹Ø×ÊÁÏ£¬
1¡¢ ¡¶ XML merging made easy
¡·
2 ¡¢¡¶javaÖкϲ¢xmlÎĵµµÄÉè¼ÆÓëʵÏÖ
¡·
²âÊÔºó·¢ÏÖ¾ù²»·ûºÏʵ¼ÊÐèÇó£¬Êµ¼ÊÐèÇóÈçÏ£º
file1.xml:
<root>
<a>
<b name="1"/>
</a>
<d /& ......
1 ËùÓÐµÄ .java|.jsp|.html|.xml Ô´Îļþ¾ùʹÓÃutf-8±àÂë¸ñʽ±£´æµ½ÏµÍ³´ÅÅÌ¡£
È磺ÔÚEclipseÖбà¼Îļþ£¬Ñ¡ÖÐÎļþ´ò¿ªÓÒ¼ü²Ëµ¥Ñ¡ÔñÊôÐÔ£¬½«Îı¾Îļþ±àÂëÉèÖÃΪÆäËû²¢Ñ¡ÔñUTF-8£»Ò²¿ÉÒÔÔÚ
Eclipse——Ê×Ñ¡Ïî——³£¹æ——ÄÚÈÝÀàÐÍÖÐÉèÖø÷ÖÖÎļþµÄȱʡ±àÂ룬ÕâÑùÒÔºóËùÓеÄÎı¾Îļþ¶¼Ê¹ÓÃÍ³Ò ......