VC¶ÁдXMLÎļþ
MSXML2::IXMLDOMDocumentPtr pDoc;
MSXML2::IXMLDOMElementPtr xmlRoot ;
// ´´½¨DOMDocument¶ÔÏó
HRESULT hr = pDoc.CreateInstance(__uuidof(MSXML2::DOMDocument40));
if ( ! SUCCEEDED(hr))
{
MessageBox( " ÎÞ·¨´´½¨DOMDocument¶ÔÏó£¬Çë¼ì²éÊÇ·ñ°²×°ÁËMS XML Parser ÔËÐпâ! " );
return ;
}
// ¸ù½ÚµãµÄÃû³ÆÎªBook
// ´´½¨ÔªËز¢Ìí¼Óµ½ÎĵµÖÐ
xmlRoot = pDoc -> createElement((_bstr_t) " Book " );
// ÉèÖÃÊôÐÔ
xmlRoot -> setAttribute( " id " ,( const char * )m_strId);
pDoc -> appendChild(xmlRoot);
MSXML2::IXMLDOMElementPtr pNode;
// Ìí¼Ó“author”ÔªËØ
pNode = pDoc -> createElement((_bstr_t) " Author " );
pNode -> Puttext((_bstr_t)( const char * )m_strAuthor);
xmlRoot -> appendChild(pNode);
// Ìí¼Ó“Title”ÔªËØ
pNode = pDoc -> createElement( " Title " );
pNode -> Puttext(( const char * )m_strTitle);
xmlRoot -> appendChild(pNode);
// ±£´æµ½Îļþ
// Èç¹û²»´æÔھͽ¨Á¢,´æÔھ͸²¸Ç
pDoc -> save( " d:\\he.xml " );
------------------------------------------------------------------------------------------------------------------------------------------------
MSXML2::IXMLDOMDocumentPtr pDoc;
HRESULT hr;
hr = pDoc.CreateInstance(__uuidof(MSXML2::DOMDocument40));
if (FAILED(hr))
{
MessageBox( " ÎÞ·¨´´½¨DOMDocument¶ÔÏó£¬Çë¼ì²éÊÇ·ñ°²×°ÁËMS XML Parser ÔËÐпâ! " );
return ;
}
// ¼ÓÔØÎļþ
pDoc -> load( " d:\\he.xml " );
MSXML2::IXMLDOMNodePtr pNode;
// ÔÚÊ÷ÖвéÕÒÃûΪBookµÄ½Úµã," // "±íʾÔÚÈÎÒâÒ»²ã²éÕÒ
pNode = pDoc -> selectSingleNode( " //Book " );
MSXML2::DOMNodeType nodeType;
&nbs
Ïà¹ØÎĵµ£º
ƽʱ×öÓÎÏ·¿ª·¢µÄʱºò£¬ºÜ´ó³Ì¶ÈÉ϶¼»á²ÉÓÃxmlÀ´×öÅäÖÃÎļþ¡£ÓÐʱºòÐèҪдºÜ¶à£¬È»ºóÓÖÐèÒªÒÀ´ÎÈ¥½âÎö¡£Èç¹ûÓÐÒ»¸ö¹¤¾ßÀ´×Ô¶¯½âÎöÿһ¸öxml£¬²¢ÇÒÌáÈ¡³ö×Ô¼ºÐèÒªµÄÊý¾Ý£¬¶àºÃѽ¡£ËùÒÔ͵Á˸öÀÁ£¬Ð´ÁËÒ»¸ö½âÎöÒ»¶¨¸ñʽµÄxmlºÍ½âÎöÀ࣬°ÑÕâ¸ö¸ñʽ¶ª¸ø²ß»®×Ô¼ºÈ¥µ÷ÕûÊý¾ÝÀ²¡£Í¬Ê±×Ô¼ºÕâ±ßÖ»ÐèÒª½ÓÊÜÏֳɵÄÀà
×¢Ò⣬ÕâÀïµÄÖ¸µÄÀ ......
1¡¢mian.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="HTTPSrv.send();" width="242" height="442">
<mx:Script>
<!--[CDATA[
import mx.rpc.events.ResultEv ......
ÒÔÏÂΪһÌìµÄ»ù±¾Ñ§Ï°Çé¿ö£¬°üÀ¨Ñ§Ï°ºÍ¸´Ï°£¬Ä£Ê½²¿·ÖǰǰºóºóÒ²¿´Á˺ܶàÁË£¬µ«ÊÇһֱûÄܼá³Ö¿´Í꣬ϣÍûÕâ´Î¿ÉÒÔ¼á³ÖÏÂÈ¥¡£
ģʽ²¿·ÖÎÒûÓÐÖ±½ÓÈ¥¿´±È½Ï¾µäµÄ¡¶javaÓëģʽ¡·£¬ÕâÊéÌ«ºñÈÝÒ×ÈÃÎÒ¼á³Ö²»ÏÂÈ¥£¬¶øÊDzÉÓÃÁ˳̽ÜдµÄ¡¶´ó»°Éè¼ÆÄ£Ê½¡·£¬
ÕâÊéдµÄºÜÓÐÒâ˼£¬Ò²ºÜÈÝÒ×Àí½â¡£Ï£ÍûÕâÑùµÄÊé¿ÉÒÔ¶àЩ¡£ºÇºÇ£¬µ±È»µÈ¿´ ......
Ïêϸ½éÉÜFlexÖвÙ×÷XML(ÉÏ)
2009Äê12ÔÂ30ÈÕ ÐÇÆÚÈý 12:05
Ò» ÔÚ½éÉÜFlexÖвÙ×÷XML֮ǰ£¬Ê×Ïȼòµ¥½éÉÜÏÂXMLÖеĻù±¾ÊõÓï¡£
ÔªËØ£ºXMLÖÐÓµÓпªÊ¼±êÇ©ºÍ½áÊø±êÇ©µÄÕâÒ»¿é³ÆÎª“ÔªËØ”
½Úµã£º°ÑXMLÔªËØÓëÎı¾½áºÏÆðÀ´Í³³ÆÎª½Úµã
¸ù½Úµã£ºÎ»ÓÚÕû¸öXMLÎÄ ......
xmlÎļþÈçÏ£º<?xml version="1.0" encoding="gb2312"?>
<Èí¼þ¹ÜÀíϵͳ>
<¹ÜÀíÔ±>
<Óû§Ãû>Ã÷ÈտƼ¼</Óû§Ãû>
<ÃÜÂë>123456</ÃÜÂë>
<µØÖ·>³¤´ºÊÐ</µØÖ·>
</¹ÜÀíÔ±>
<¹ÜÀíÔ±>
<Óû§Ãû>Ã÷ÈÕÈí¼þ</Óû§Ãû ......