ASP tutorial. NET C + + output XML code
#include "stdafx.h"
using namespace System;
using namespace System::configuration;
Using namespace system::d ATA;
Using namespace system::d ata::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);
}
Load XML file to 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++)
{ br> 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);
}
}