¼òµ¥½âÎöXML - Òƶ¯Æ½Ì¨ / Android
XML code:
<?xml version="1.0" encoding="utf-8" ?>
- <info>
<status>ok</status>
<error />
- <item>
<uid>819789</uid>
<show>ºÃµÄ</show>
<email />
</item>
</info>
- <item>
<uid>819780</uid>
<show>ºÃµÄ2</show>
<email>eee@222.com<email>
</item>
- <item>
<uid>819720</uid>
<show>ºÃµÄ3</show>
</item>
</info>
Èç¹ûstatusΪokµÄÇé¿öÏÂ,¾Í¶ÁÈ¡itemµÄÊôÐÔ
²ÉÓÃorg.w3c.dom½âÎö.
¸ÕѧJAVA.ÔÚXMLÉϾÍÓÐÎÊÌâÁË.ÉÏÍøÕÒÁËЩ.ºÇºÇ.Ö÷ÒªÊǶÔÓÚÀýÈç<email /> µÄֵΪ¿Õ»òÕßûÓÐ<email>Õâ¸ö½ÚµãÒªÈçºÎÅжÏ.
¶¥Ò»ÏÂ.
ÓÃandroid×Ô´øµÄ½âÎöÆ÷ SAX ½âÎöÆðÀ´Ëٶȷdz£¿ì ¶øÇÒͦ¼òµ¥µÄ
Èç¹û½âÎöstatusΪok ¾ÍÉèÖÃÒ»¸öboolean ÒòΪSAXÊÇÖðÐнâÎöµÄ Èç¹ûΪTRUEµÄ»° ¾Í½âÎöÏÂÒ»¸ö Èç¹ûÊÇFALSE ¾Íreturn ÕâÑù¾Í¿ÉÒÔÁË ¿´ÏÂsdkµÄÎĵµ
ÓÃSAXÒ»¶¨ÒªBaseFeedParserÂï?
ÕâÑùÓÐʲôºÃ´¦ÄØ?
²»ÄÜÖ±½Ó¾Ínew Ò»¸ö¶ÔÏó.È»ºó¶Áȡij¸ö×Ö½ÚµÄÊý¾ÝÕâÑùÂð?
¿´Á˺öà.ÓеãÔÎ.ºÇºÇ.
ÓÃSAX¹¤³§ÀàÉú³ÉËü È»ºó¶¨ÒåDefaultHandler ¶¨Òå½âÎöXMLµÄ¹æÔò
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser parser = factory.newSAXParser();
È»ºóparser
Ïà¹ØÎÊ´ð£º
txt ºÍXML ¸ñʽÏàÓ¦
²»½èÖúDataSet
µ¼Èë¶ÁÈ¡TXTÎļþ
È»ºóÖ±½ÓдÈëXML(ͬһÎļþ,²»Í¬Êý¾Ý,µÝÔöÔÊý¾ÝûÓб»¸²¸ÇÇé¿öÏÂÔö¼ÓÊý¾Ý.)
½Ì¸öÒªµã»ò×îºÃÊÇÓиö´úÂëÌáʾµÄ
¹ý·ºÃºº °ï¸öæÈö^^
²»»á£¬°ïÂ¥Ö÷ ......
Êý¾Ý¿â±íÖÐÓÐÒ»ÁУ¨TranXml£©ÀàÐÍÊÇxml£¬´æ´¢µÄÊÇÀàËÆ
<fathernode>
<a>aaa
</a>
<b>bbb
</b>
</fathernode>
µÄÐÅÏ¢£¬²¢ÇÒͨ¹ý²éѯ·½· ......
ÈçºÎÓÃATL´°ÌåÓ¦ÓóÌÐòÖÐÓÃSystem.Xml±éÀúÒ»¸öXmlÎļþ
Äã˵µÄÊÇÍйܴúÂ룿
¡£
vc¿ÉÓÃmsxml
http://msdn.microsoft.com/en-us/library/ms767594(VS.85).aspx
MSXML4
//ÒýÈëmsxml4.dll &nbs ......
ÎÒÓÃXmlDocumentÉú³ÉXML
XmlElement remarkNode = node.OwnerDocument.CreateElement("remark");
remark1Node.InnerXml = "";
Èç¹ûInnerXml¸³Öµ²»Îª¿Õ£¬ÔòÉú³ÉµÄ±ê¼ÇÊÇûÎÊÌâµÄ£¬±ÈÈ磺<r ......