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;
}
¢Ù¶¨Òå½âÎöÎĵµÖ¸Õë¡£
¢Ú¶¨Òå½áµ
Ïà¹ØÎĵµ£º
¿ª·¢¹ýAndroidÓ¦ÓõÄͬѧÃǶ¼ÖªµÀ£¬Android¹¤³Ì-res-layout×ÊÔ´Îļþ¼ÐÏ´æ·Å×Å¿ØÖÆview²¼¾ÖµÄxmlÎļþ£¬ÎÒÃÇ¿ÉÒÔͬ¹ýgetViewById(int i)·½·¨£¬´ÓXMLÖй¹Ôìview¼°Æä×ÓÀ࣬ÔÚÕâ¸ö¹ý³Ìµ±ÖУ¬XMLÎļþÖеÄÒ»ÇÐlayoutÊôÐÔÒ²½«±»¸³ÓèÕâ¸öview¡£µ±È»£¬ÎÒÃÇÒ²Äܹ»Í¨¹ý´úÂëÀ´ÎªÄ³Ò»¸öviewÀ´ÉèÖÃlayout£¬ÄÇÊǺ󻰡£Í¨¹ý¶Ô¼ ......
1.Òª½âÎöµÄXMLÎļþÈçÏ£º
<?xml version="1.0" encoding="GB2312"?>
<?xml-stylesheet href="student.xsl" type="text/xsl"?>
<StudentInfo>
<student>
<name>´ïÄÚ</name>
<sex>ÄÐ</sex>
<lesson>
  ......
JAXBContext jc = JAXBContext.newInstance(ICPBuildSummaryXO.class);
Unmarshaller u = jc.createUnmarshaller();
ICPBuildSummaryXO xo = (ICPBuildSummaryXO) u.unmarshal(node);
ICPBuildSummary summary = new ICPBuildSummary();
Bean ......
windows xpÏÂIIS°²×°ºó¡£
¿ªÊ¼ÏÔʾµÄ´íÎóΪ
ÎÞ·¨ÏÔʾ XML Ò³¡£
ʹÓà Ñùʽ±íÎÞ·¨²é¿´ XML ÊäÈë¡£Çë¸üÕý´íÎóÈ»ºóµ¥»÷ ˢа´Å¥£¬»òÒÔºóÖØÊÔ¡£
------------------------------------------------------------------------- ......
package com.flxx.docUrl;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
import org.jdom.output.Format;
import org.jd ......