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

ʹÓÃTinyXml½âÎöXmlʾÀý

// TestXml.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <windows.h>
#include "tinyxml.h"
#include "lang.h"
#include <string>
using namespace std;
using namespace std;
#pragma comment(lib, "tinyxmld.lib")
BOOL LoadXml(TiXmlDocument&doc, LPCTSTR lpszSrcPath);
BOOL SaveXml(TiXmlDocument&doc, LPCTSTR lpszDstPath);
BOOL GetDeclare(TiXmlDocument&doc);
BOOL ReadXmlText(TiXmlDocument&doc);
BOOL ParseXmlText(TiXmlElement* pEleRoot);
BOOL ReadXmlAttr(TiXmlDocument&doc);
BOOL ParseXmlAttr(TiXmlElement* pEleRoot);
BOOL AddNode(TiXmlDocument& doc);
BOOL DelNode(TiXmlDocument& doc);
int _tmain(int argc, _TCHAR* argv[])
{
TiXmlDocument doc;
//load xml
if (!LoadXml(doc, "./test_copy.xml"))
{
return -1;
}
//get declare
GetDeclare(doc);
//add and del
DelNode(doc);
AddNode(doc);


cout << "============================Read Text==========================" << endl;
//read text
ReadXmlText(doc);
cout << "============================Read Attribute==========================" << endl;
//read attribute
ReadXmlAttr(doc);
if (!SaveXml(doc, "./test2.xml"))
{
return -1;
}
return 0;
}
BOOL LoadXml(TiXmlDocument&doc, LPCTSTR lpszSrcPath)
{
//load file
if (!doc.LoadFile(lpszSrcPath))
{
cout << "load xml failed!" << endl;
return FALSE;
}
//print
doc.Print();
return TRUE;
}
BOOL SaveXml(TiXmlDocument&doc, LPCTSTR lpszDstPath)
{
//save file
if (!doc.SaveFile(lpszDstPath))
{
cout << "save xml failed!" << endl;
}
else
{
cout << "save xml succ!" << endl;
}
return TRUE;
}
BOOL GetDeclare(TiXmlDocument&doc)
{
TiXmlNode* pXmlFirst = doc.FirstChild();
if (NULL != pXmlFirst)
{
TiXmlString str;
TiXmlDeclaration* pXmlDec = pXmlFirst->ToDeclaration();
if (NULL == pXmlDec)
{
pXmlDec-


Ïà¹ØÎĵµ£º

XML CDATA

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

asp.net ¶ÔxmlÎļþµÄ¶Áд,Ìí¼Ó,ÐÞ¸Ä,ɾ³ý²Ù×÷

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Xml;
private XmlDo ......

ÀûÓÃSqlHelper(ExecuteXmlReaderʹÓÃ)£¬×ª»»µ½xml¸ñʽ

ÀûÓÃsqlhelperÖеÄExcuteXmlReader·½·¨£¬¶ÁÈ¡Êý¾Ý²¢±£´æÎªxmlÎļþ     
 string strConn = Properties.Settings.Default.Connections;
           SqlConnection connection = new SqlConnection(strConn);
    & ......

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

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