最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp.net C++输出 xml代码
时间:2022-06-25 06:35:37 编辑:袖梨 来源:一聚教程网
asp教程.net c++输出 xml代码
#include "stdafx.h"
using namespace system;
using namespace system::configuration;
using namespace system::data;
using namespace system::data::sqlclient;
using namespace system::xml;void navigate(xmlnode ^node, int depth)
{
if (node == nullptr)
return;console::writeline(depth);
console::writeline(node->nodetype.tostring());
console::writeline(node->name);
console::writeline(node->value);if (node->attributes != nullptr)
{
for (int i = 0; i < node->attributes->count; i++)
{
console::writeline(node->attributes[i]->name);
console::writeline(node->attributes[i]->value);
}
}navigate(node->firstchild, depth+1);
navigate(node->nextsibling, depth);
}
void main(){
xmldocument ^doc = gcnew xmldocument();sqlconnection ^connect = gcnew sqlconnection();
connect->connectionstring = "sqlconnection";
sqldataadapter ^dadapt = gcnew sqldataadapter();
dataset ^dset = gcnew dataset();
dadapt->selectcommand = gcnew sqlcommand("select * from authors", connect);
dadapt->fill(dset, "authors");
xmldatadocument ^doc1 = gcnew xmldatadocument(dset);navigate(doc1->documentelement, 0);
}
加载xml 文件到 xmldocument
#include "stdafx.h"
using namespace system;
using namespace system::xml;
void navigate(xmlnode ^node, int depth)
{
if (node == nullptr)
return;console::writeline(depth);
console::writeline(node->nodetype.tostring());
console::writeline(node->name);
console::writeline(node->value);if (node->attributes != nullptr)
{
for (int i = 0; i < node->attributes->count; i++)
{
console::writeline(depth+1);
console::writeline(node->attributes[i]->name);
console::writeline(node->attributes[i]->value);
}
}
navigate(node->firstchild, depth+1);
navigate(node->nextsibling, depth);
}
void main()
{
xmldocument ^doc = gcnew xmldocument();
try
{
xmlreader ^reader = xmlreader::create("..monsters.xml");
doc->load(reader);
reader->close();
xmlnode ^node = doc->firstchild;
navigate(node, 0);
}
catch (exception ^e)
{
console::writeline("error occurred: {0}", e->message);
}
}
相关文章
- 《原神》5.2卡池抽取建议 11-14
- 《原神》5.2版本新怪物介绍 11-14
- 《原神》希诺宁增伤触发方法 11-14
- 《原神》循音觅奇活动入口 11-14
- 《原神》循音觅奇兑换码获取方法 11-14
- 《原神》花羽会活动飞行技巧介绍 11-14