Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

xml½âÎö¶àÖؽڵã

xmlΪ£º
<friendShares>
<totalCount>352</totalCount>
<friendShare>
<code>XXXXXXX</code>
<date>2010-01-15T00:00:00+08:00</date>
<friendId>499</friendId>
<movie>
<code>XXXXXX</code>
<contentId>89718</contentId>
<movieName>»ú¶¯²¿¶Ó¾¯Àý</movieName>
<picPath>/20090817/189736.gif</picPath>
</movie>
<nickName>xjmy</nickName>
<recommendId>32769</recommendId>
<uid>499</uid>
</friendShare>
<friendShare>
<code>XXXXXXX</code>
<date>2010-01-15T00:00:00+08:00</date>
<friendId>499</friendId>
<movie>
<code>XXXXXX</code>
<contentId>89718</contentId>
<movieName>»ú¶¯²¿¶Ó¾¯Àý</movieName>
<picPath>/20090817/189736.gif</picPath>
</movie>
<nickName>xjmy</nickName>
<recommendId>32769</recommendId>
<uid>499</uid>
</friendShare>
</friendShares>
java´úÂ룺
Document doc;
try {
doc = DocumentBuilderFactory.newInstance().newDocumentBuilder()
.parse(new InputSource(new StringReader(xml)));
NodeList nl = doc.getElementsByTagName("totalCount");
if(doc.getElementsByTagName("totalCount").item(0)!=null){
if(doc.getElementsByTagName("totalCount").item(0).getFirstChild()!=null){
int totalCount=Integer.parseInt(doc.getElementsByTagName("totalCount").item(0).getFirstChild().getNodeValue());
nl = doc.getElementsByTagName("friendShare");
for (int i=0;i<nl.getLength();i++){
IptvMembers members=new IptvMembers();
members.setCount(totalCount);
if(doc.getElementsByTagName("date").item(i)!=null){
if(doc.getElementsByTagName("date").item(i).getFirstChild()!=null){
String date=doc.getElementsByTagName("date").item(i).getFirstChild().getNodeValue();
date=date.replaceAll("T&q


Ïà¹ØÎĵµ£º

XMLÎļþѧϰ

XML CDATA Îı¾
ËùÓÐ XML ÎĵµÖеÄÎı¾¾ù»á±»½âÎöÆ÷½âÎö¡£
Ö»ÓÐ CDATA Çø¶Î£¨CDATA section£©ÖеÄÎı¾»á±»½âÎöÆ÷ºöÂÔ¡£
Parsed Data
XML ½âÎöÆ÷ͨ³£»á½âÎö XML ÎĵµÖÐËùÓеÄÎı¾¡£
µ±Ä³¸ö XML ÔªËر»½âÎöʱ£¬Æä±êÇ©Ö®¼äµÄÎı¾Ò²»á±»½âÎö£º
<message>´ËÎı¾Ò²»á±»½âÎö</message>
½âÎöÆ÷Ö®ËùÒÔÕâô×öÊÇÒòÎ ......

XML CDATA

 
ÔÚXMLÎĵµÖеÄËùÓÐÎı¾¶¼»á±»½âÎöÆ÷½âÎö¡£
Ö»ÓÐÔÚCDATA²¿¼þÖ®ÄÚµÄÎı¾»á±»½âÎöÆ÷ºöÂÔ¡£
½âÎöÊý¾Ý
XML ½âÎöÆ÷ͨ³£Çé¿öÏ»ᴦÀíXMLÎĵµÖеÄËùÓÐÎı¾¡£
µ±XMLÔªËر»½âÎöµÄʱºò£¬XMLÔªËØÄÚ²¿µÄÎı¾Ò²»á±»½âÎö:
<message>This text is also parsed</message>
XML½âÎöÆ÷ÕâÑù×öµÄÔ­ÒòÊÇXMLÔªËØÄÚ²¿¿ÉÄÜ» ......

XML ½âÎöc++Ô´Â루ͷÎļþ£©

/*
 * XMLTool.h ÅäÖÃÎļþ½âÎö¶¯Ì¬¿âÍ·Îļþ
 *  Ö÷ÒªÊä³öº¯Êý½Ó¿Ú·Ö±ðʵÏÖ¶ÔÅäÖÃÎļþµÄ¶ÁÈ¡ºÍдÈ룬Õë¶Ô½á¹û¼¯µÄ¸´ÖÆÇå¿Õ£¬ºÍÁ½¸ö×Ö·û´®´¦Àíº¯Êý
 *  ¶ÁÈ¡ÅäÖÃÎļþ½Ó¿Ú £ºint ReadXMLFile(XML_Node_Vector *XmlNodeVector, string filepath);
 *  Ð´ÈëÅäÖ ......

¼òµ¥µÄXMLÎļþ¶Áд £¨×ª£©

×¼±¸
¿ª·¢¹¤¾ß£ºVS2005£¬
Ç°Ì᣺°²×°msxml6½âÎöÆ÷£¬msÍøÕ¾¿ÉÏÂÔØ
ͨ¹ýÏòµ¼´´½¨VC++ MFC ¹¤³Ì£¬»ùÓÚ¶Ô»°¿ò
Ìí¼ÓÒýÓÃ:
//ÔÚStdAfx.hÖÐÒýÈ붯̬Á´½Ó¿â MSXML.DLL(C:\windows\system32\msxml6.dll)
#import <msxml6.dll>
±à¼­×ÊÔ´£¬Ìí¼Ó¿Ø¼þ
ÔÚbookid¶ÔÓ¦µÄÎı¾¿òÓÒ¼ü£¬Ìí¼Ó±äÁ¿°ó¶¨£¨ÈçÏÂͼ£¬°ó¶¨¿Ø¼þÖµ£¬±äÁ¿Ã ......

java½âÎöxmlµÄ¾ßÌåÁ÷³Ì

java ´úÂë
import javax.xml.parsers.DocumentBuilder;   
import javax.xml.parsers.DocumentBuilderFactory;   
  
import org.w3c.dom.Document;   
import org.w3c.dom.Element;   
import org.w3c.dom.NodeList;    ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ