最新下载
热门教程
- 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);
}
}
相关文章
- 《无限暖暖》天星之羽获得位置介绍 12-20
- 《流放之路2》重铸台解锁方法介绍 12-20
- 《无限暖暖》瞄准那个亮亮的成就怎么做 12-20
- 《无限暖暖》魔气怪终结者完成方法 12-20
- 《无限暖暖》曙光毛团获得位置介绍 12-20
- 《无限暖暖》日光果获得位置介绍 12-20