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
Ïà¹ØÎĵµ£º
µ±ÎÒÃÇÓÃWINDOWSËÑË÷ij°üº¬Ä³ÎÄ×ÖµÄÎļþʱ£¬¿ÉÒÔÔÚ“°üº¬ÎÄ×Ö”´¦ÌîÉÏËÑË÷´Ê¡£µ«ÊÇһЩ²»³£¼ûµÄºó׺ÃûÎļþWINDOWS²»»áËÑË÷£¬È磺£¬.log¡¢.dll¡¢.js¡¢.asp¡¢.xml¡¢.xsl¡¢.hta¡¢.css¡¢.wsh¡¢.cpp¡¢.c »ò .hµÈ¼°ÎÞºó׺ÃûµÄÎļþ¡£¶ÔÓÚÎҵȳÌÐò°®ºÃÕßÀ´ËµÊµÔÚÌ«²»·½±ãÁË£¬ËäÈ»ÓГÎı¾Ìæ»»´óʦ”µÈÈí¼þÄÜ×öÕ ......
Input.xml-----------
<?xml version="1.0" encoding="gb2312"?>
<studentList>
<student sex="man">
<name>wgy</name>
<age>23</age>
<tel>12345678</tel>
</student>
<student sex="female">
<name>lemon</name&g ......
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Xml;
using System.Data;
public class Cls_XML
{
#region ´´½¨xmlÎļþ
/// <summary>
/// ´´½¨xmlÎļþ
/// ......
xmlÎļþÈçÏ£º<?xml version="1.0" encoding="gb2312"?>
<Èí¼þ¹ÜÀíϵͳ>
<¹ÜÀíÔ±>
<Óû§Ãû>Ã÷ÈտƼ¼</Óû§Ãû>
<ÃÜÂë>123456</ÃÜÂë>
<µØÖ·>³¤´ºÊÐ</µØÖ·>
</¹ÜÀíÔ±>
<¹ÜÀíÔ±>
<Óû§Ãû>Ã÷ÈÕÈí¼þ</Óû§Ãû ......