Hi all,
I read the Microsoft KB Q815658 "How to read the XML data from a file using
Visual C++ .NET" and tried to follow the steps of executing its source code
in my VC++ .NET 2003 under Console Application (.NET). I lauched a project
'Q815658XMLRead' (see the attached .cpp file below) and did the "Build" and I
got the following 2 errors:
c:\Documents and Settings\Scott H. Chang\My Documents\Visual Studio
Projects\Q815658XMLRead\Q815658XMLRead.cpp(13): error C2144: syntax error :
'int' should be preceded by ';'
c:\Documents and Settings\Scott H. Chang\My Documents\Visual Studio
Projects\Q815658XMLRead\Q815658XMLRead.cpp(13): fatal error C1004: unexpected
end of file found
Please help and tell me where I made mistakes and how to correct these 2
errors.
Thanks in advance,
SHC
/////////---Q815658XMLread.cpp----////////////
// This is the main project file for VC++ application project
// generated using an Application Wizard.
#include "stdafx.h"
#include <tchar.h>
#using <mscorlib.dll>
#using <system.xml.dll>
using namespace System;
using namespace System::Xml
int _tmain(int argc, char* argv[])
{
XmlTextReader* reader = new XmlTextReader ("books.xml");
while (reader->Read())
{
switch (reader->NodeType)
{
case XmlNodeType::Element: // The node is an element.
Console::Write("<{0}", reader->Name);
while (reader->MoveToNextAttribute()) // Read the attributes.
Console::Write(" {0}='{1}'", reader->Name, reader->Value);
Console::WriteLine(">");
break;
case XmlNodeType::Text: //Display the text in each element.
Console::WriteLine (reader->Value);
break;
case XmlNodeType::EndElement: //Display the end of the element.
Console::Write("</{0}", reader->Name);
Console::WriteLine(">");
break;
}
}
Console::ReadLine();
}