| |
Does it have attribute |
|
#include "stdafx.h"
#using <system.xml.dll>
using namespace System;
using namespace System::Xml;
void main()
{
XmlReader ^reader;
reader = XmlReader::Create("..\\Monsters.xml");
while (reader->Read()){
switch (reader->NodeType)
{
case XmlNodeType::Comment:
Console::WriteLine(reader->Depth);
Console::WriteLine(reader->Value);
break;
case XmlNodeType::Element:
Console::WriteLine(reader->Depth);
Console::WriteLine(reader->Name);
if (reader->HasAttributes)
{
while (reader->MoveToNextAttribute())
{
Console::WriteLine(reader->Depth);
Console::WriteLine(reader->Name);
Console::WriteLine(reader->Value);
}
reader->MoveToElement();
}
if (reader->IsEmptyElement)
{
Console::WriteLine(reader->Depth);
Console::WriteLine(reader->Name);
}
break;
case XmlNodeType::EndElement:
Console::WriteLine(reader->Depth);
Console::WriteLine(reader->Name);
break;
case XmlNodeType::Text:
Console::WriteLine(reader->Depth);
Console::WriteLine(reader->Value);
break;
case XmlNodeType::XmlDeclaration:
Console::WriteLine(reader->Depth);
Console::WriteLine(reader->Name);
if (reader->HasAttributes)
{
while (reader->MoveToNextAttribute())
{
Console::WriteLine(reader->Depth);
Console::WriteLine(reader->Name);
Console::WriteLine(reader->Value);
}
}
reader->MoveToElement();
Console::WriteLine(reader->Depth);
Console::WriteLine(reader->Name);
break;
case XmlNodeType::Whitespace:
break;
default:
Console::WriteLine("***UKNOWN*** node");
Console::WriteLine(reader->Depth);
Console::WriteLine(reader->Name);
Console::WriteLine(reader->Value);
}
}
}
|
|
|
Related examples in the same category |
|