¹ØÓÚÀûÓÃcmarkupÀཫxmlת³ÉÊ÷µÄµÝ¹é´úÂë
½üÀ´×Ô¼ºÔÚ×öxmlµÄ½âÎöÆ÷¡£ÀûÓõ½ÁËcmarkupÀ࣬¾Íµ±×ö´æ´¢°É£¡ÓÐÐèÒªµÄÅóÓÑ¿ÉÒÔÃ鼸ÑÛ¡£
HTREEITEM itemTemp1,itemTemp2;
CString str1,str2;
char strtemp[100];
static bool result = true;
strtemp[0] = 0;
if (result)
{
xml.FindElem();
}
result = false;
str1 = xml.GetTagName();
strcpy(strtemp,(char*)(LPCTSTR)str1);
itemTemp1 = m_treectrl.InsertItem(str1,item);
if (xml.FindChildElem())
{
xml.IntoElem();
LoadXmlItem(itemTemp1);
xml.OutOfElem();
}
while(xml.FindElem())
{
str1 = xml.GetTagName();
strcpy(strtemp,(char*)(LPCTSTR)str1);
itemTemp2 = m_treectrl.InsertItem(str1,item);
if (xml.FindChildElem())
{
xml.IntoElem();
AfxMessageBox("cc");
LoadXmlItem(itemTemp2);
xml.OutOfElem();
}
//nRes = xml.FindElem();
}
Óöµ½¸öÎÊÌ⣺ ²»ÖªµÀÈçºÎ»ñÈ¡ÊôÐÔÃû³ÆºÍÊôÐÔµÄÊýÁ¿ÎÊÌ⣬ÍûÖªµÀµÄÅóÓÑÄÜ°ï°ïÔÚÏ¡£
Ïà¹ØÎĵµ£º
½ÓÉÏһƪ
ɾ³ýÔgenreÊôÐÔ£¬É¾³ýleixing=loveµÄËùÓнáµã¡£
1 ÔxmlÎļþ bookstore.xml
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book genre="love" ISBN="1234123">
<title>who am i </title>
<author>who</aut ......
DOM³õ²½
DOMÊÇDocument Object ModelµÄËõд£¬¼´Îĵµ¶ÔÏóÄ£ÐÍ¡£Ç°Ãæ˵¹ý£¬XML½«Êý¾Ý×é֯Ϊһ¿ÅÊ÷£¬ËùÒÔDOM¾ÍÊǶÔÕâ¿ÅÊ÷µÄÒ»¸ö¶ÔÏóÃèÐð¡£Í¨Ë×µÄ˵£¬¾ÍÊÇͨ¹ý½âÎöXMLÎĵµ£¬ÎªXMLÎĵµÔÚÂß¼ÉϽ¨Á¢Ò»¸öÊ÷Ä£ÐÍ£¬Ê÷µÄ½ÚµãÊÇÒ»¸ö¸ö¶ÔÏó¡£ÎÒÃÇͨ¹ý´æÈ¡ÕâЩ¶ÔÏó¾ÍÄܹ»´æÈ¡XMLÎĵµµÄÄÚÈÝ¡£
ÏÂÃæÎÒÃÇÀ´¿´Ò»¸ö¼òµ¥µÄÀý×Ó£¬¿´¿´ÔÚDOMÖ ......
ÏÂÃæµÄÄÚÈÝ£¬ÎÒÃǽ«¸ü¶àµÄ¹Ø×¢DOM£¬ÎªDOM×÷Ò»¸ö½ÏΪÏêϸµÄ½âÎö£¬Ê¹ÎÒÃÇʹÓÃÆðÀ´¸üΪµÃÐÄÓ¦ÊÖ¡£
DOMÏê½â
1£®»ù±¾µÄDOM¶ÔÏó
DOMµÄ»ù±¾¶ÔÏóÓÐ5¸ö£ºDocument£¬Node£¬NodeList£¬ElementºÍAttr¡£ÏÂÃæ¾ÍÕâЩ¶ÔÏóµÄ¹¦ÄܺÍʵÏֵķ½·¨×÷Ò»¸ö´óÖµĽéÉÜ¡£
Document¶ÔÏó´ú±íÁËÕû¸öXMLµÄÎĵµ£¬ËùÓÐÆäËüµÄNode£¬¶¼ÒÔÒ»¶¨µÄ˳Ðò°üº ......
Õâ¸öÊDzÎÕÕibmÍøÕ¾ÉϵÄÎÄÕÂ×öµÄ¡£
xmlÔ´Îļþ£º
<?xml version="1.0"?>
<!DOCTYPE rss PUBLIC
"-//Netscape Communications//DTD RSS 0.91//EN"
"http://my.netscape.com/publish/formats/rss-0.91.dtd"
>
<rss version="0.91">
<channel>
<title>Meerkat: An Open2 Wire Servic ......
5. ÃüÃû¹æÔò£¨²»ÄÜ°üÀ¨ xml£¬¿Õ¸ñ£¬¼âÀ¨ºÅ£¬µÈÌØÊâ·ûºÅ£¬²»ÄÜÊý×Ö¿ªÍ·£©
6. ¿ÉÒÔ×Ô´øÊôÐÔ¡£ÊôÐÔÖµÓÓ”±êʾ
7. ×¢ÊÍ<!--×¢Ê͵ÄÄÚÈÝ-->
8. Èç¹ûÒªÏÔʾÌØÊâ·ûºÅ¿ÉÓÃ<![CDATA[ ÕâÀïдÌØÊâ·ûºÅ ]]>
´´½¨
var xml:XML=<shuiGuo>
& ......