日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

XML字符串的讀寫操作函數(shù)及示例程序_Xml教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:如何在HTML中引用XML數(shù)據(jù)
1,內(nèi)嵌XML數(shù)據(jù) <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=gb2312"> <title>第一次親密接觸(非

以下為引用的內(nèi)容:

// OpXML.cpp : Defines the entry point for the console application.
//

//----------------------- Coded By Ronk --------------------------//
//----------------------- 2005-07-17 --------------------------//

#include "stdafx.h"
#include <stdio.h>

//---You must Setup the MSXML4.0 before using
#import <msxml4.dll>
using namespace MSXML2;

void xmlread(char *ch1,char *ch2,char *ch3);//Read the xmlstr and Get the Text of the Element

void xmlupdate(char *ch1,char *ch2,char *ch3);//Read the xmlstr and Update the Text of the Element

int main(int argc, char* argv[])
{
char xmlstr[1024]="<inesmsg><msghead><version>LZD</version><root>ioio</root></msghead></inesmsg>";
char strele[1024]="//version//";
char textstr[1024]="NNYX";
char value[1024];

printf("The xmlstr is :\n%s\n\n",xmlstr);

xmlread(xmlstr,strele,value); //befor Update
printf("The Text of Element befor Update is: \n%s\n\n",value);

xmlupdate(xmlstr,strele,textstr);//Change the Text of "<version>" with "NNYX"
printf("The Updated xmlstr is :\n%s\n\n",xmlstr);

xmlread(xmlstr,strele,value);//after Update
printf("The Text of Element after Update is :\n%s\n\n",value);

return 0;
}


void xmlread(char* msgstr,char* elestr,char *tex)
{
//Initialize
CoInitialize(NULL);

IXMLDOMDocumentPtr pXmlDoc;
IXMLDOMNodePtr pXmlNode;

HRESULT hr;
hr = pXmlDoc.CreateInstance(__uuidof(DOMDocument));
if (FAILED(hr))
{
printf("Faild to Create XMLDom Instance !");
pXmlDoc=NULL;
}
else
{
pXmlDoc ->async = VARIANT_FALSE;

//Load xmlmsg
_bstr_t xmlstr=(LPCSTR)msgstr;

if (!(pXmlDoc->loadXML(msgstr)))
{
printf("Failed to Load xmlstr:\n%s\n",(LPCSTR)pXmlDoc->parseError->Getreason());
pXmlDoc=NULL;
}
else
{
//Locate the Element
_bstr_t str=(LPCSTR)elestr;
pXmlNode = pXmlDoc ->selectSingleNode(elestr);

if(FAILED(pXmlNode))
printf("Faild to Locate the Element \n%s\n",str);
else
{
//Read the Text of Element
strcpy(tex,(LPCSTR)pXmlNode ->text);


//Realese
pXmlDoc.Release();
pXmlNode.Release();
}
}
}
}

void xmlupdate(char *msgstr,char *elestr,char *upstr)
{
//---Initialize
CoInitialize(NULL);

IXMLDOMDocumentPtr pXmlDoc;
IXMLDOMNodePtr pXmlNode;

HRESULT hr;
hr = pXmlDoc.CreateInstance(__uuidof(DOMDocument));

if (FAILED(hr))
{
printf("Faild to Create XMLDom Instance !");
pXmlDoc=NULL;
}
else
{
pXmlDoc ->async = VARIANT_FALSE;

//Load xml str
_bstr_t xmlstr=(LPCSTR)msgstr;

if (!(pXmlDoc->loadXML(msgstr)))
{
printf("Failed to load xmlstr:\n%s\n",(LPCSTR)pXmlDoc->parseError->Getreason());
pXmlDoc=NULL;
}
else
{
//Located the Element
_bstr_t str=(LPCSTR)elestr;
pXmlNode = pXmlDoc ->selectSingleNode(elestr);

if (FAILED(pXmlNode))
printf("Failed to Locate the Element \n%s\n",str);
else
{
//Update the Text of the Element
pXmlNode->text = upstr;

//Get the New xmlstr
strcpy(msgstr,(LPCSTR)pXmlDoc->xml);

//Realese
pXmlDoc.Release();
pXmlNode.Release();
}
}
}
}

分享:WEB頁面工具語言XML支持的工具之運(yùn)用
盡管XML還處在開發(fā)階段,其標(biāo)準(zhǔn)正在由W3C組織制定,但是已經(jīng)有許多公司表示全力支持XML,并開發(fā)了不少XML工具。Adobe公司的FrameMaker可以用來書寫XML文檔。Microsoft公司推出的IE 4.0已經(jīng)可以

來源:模板無憂//所屬分類:Xml教程/更新時(shí)間:2008-08-22
相關(guān)Xml教程