473,466 Members | 1,391 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

VC++ .NET 2003: XmlTextReader Errors C2144 & C1004

SHC
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();
}

Nov 12 '05 #1
2 2760


SHC wrote:

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. using namespace System;
using namespace System::Xml

^^^
There the semicolon is missing, you need
using namespace System::Xml;
according to the error message.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 12 '05 #2
SHC
Hi Martin, Thanks for your response.
I corrected the error and did the "Build" again. On the c:\ screen, I got
the following: Microsoft Development Environment
An unhandled exception of type 'System.Xml.XmlException'
occured
in system.xml.dll
Addtional Information: System error
|Break| |Continue|
I clicked on the |Continue| and I got the following:
"c:\Documents and Settings\Scott H. Chang\My Documents\Visual Studio
Projects\Q815658XMLRead.........
unhandled Excetion: System.Xml.XmlException:
The XML declaration is unexpected.
Line 1, position 4
at System.Xml.XmlTextReader.ParseTag<>
at System.Xml.XmlTextReader.ParseRoot<>
at System.Xml.XmlTextReaderRead<>
at main (Int32argc, SByte ** argv) in
c:\documents and
settings\.....\.....\q815658xmlread\q815658xml.cpp :line 17
The Line 17 in my .cpp program is "while (read->Read())".

I am new in VC++ .NET 2003 and XML programmming in VC++ .NET. I just have my
VC++ .NET 2003 installed and this "Q815658XMLRead" is my first XML
programming project. I need to tell you the following 2 things:
1) When I read the Microsoft Q815658:How to read the XML data from a file by
using Viusual C++ .NET, I saw the step #6: Add a reference to System.xml.dll
in the project and the additional information is in the article of the
Microsoft Knowledge Base: 310674 - How To Add reference to a managedVisual
C++ project. I read it, but I did not understand it and I did not do any
thing about the "reference" in my project.
2)In the original code lisiting, void _tmain(void) was used in my project. I
changed it to int _tmain(int argc, char* argv[]) - this is based on my
guessing!!!

Did 1) and 2) cause the problem in my project? Please hehp and advise me
how I can correct the problem and make the project working for me.

Many Thanks,
SHC

P. S. I itried to abort my "Build" process after 'Debug' and 'Break'. I
clicked on the
"Build" menu, I just saw 'Configuration Managert' only and I do not
know how
to abort this process now. Please advise on this matter also.
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: geek04 | last post by:
i'm using pro*c to precompile my c++ code which accesses oracle 9i database, i'm running a oracle 9i client on my system on compiling the c++ file (generated by pro*c)i'm getting following...
0
by: Tom Lee | last post by:
Hi, I'm new to .NET 2003 compiler. When I tried to compile my program using DEBUG mode, I got the following errors in the C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7 \include\xdebug...
11
by: Michael Sgier | last post by:
Hi i trying to port my OpenGL / C++ / SDL project to VC++.NET. Why do i get those errors. The code compiles under Linux without problems. I beliebe to have set correctly the include and lib dirs...
1
by: SHC | last post by:
Hi all, I did the "Build" on the attached code in my VC++ .NET 2003 - Windows XP Pro PC. On the c:\ screen, I got the following: Microsoft Development Environment An unhandled exception of type...
6
by: SHC | last post by:
Hi all, I created an application from the Console Application (.NET) of VC++ .NET 2003, and I did "Build" the application of the attached .cpp file, volcanoes.xml and geology.dtd on my VC++ .NET...
0
by: Scott Chang | last post by:
Hi all, I tried to use Managed C++ coding of VC++.NET (2002)and OpenGL version 1.2 to draw a hexagon shape of benzene. My OpenGLdrawBenzene.cpp is the following: // This is the main project file...
1
by: Dave | last post by:
With .Net 2003 I use : #include <fstream> using namespace std; I have problem using "getline", also a debug wersion does not compiled, has problem in xdebug: c:\Program Files\Microsoft Visual...
2
by: Qiao Yun | last post by:
I used vc++.net (visual studio .net ) to open a project which can work well in vc++6.0. I succeeded in compiling the project in vc++.net in release mode . But when I tried to compile the project...
1
by: Michel | last post by:
In VC++ from Visual Studio 2005 the following occurs: If I try to compile anyting, even a newly created empty MFC application with 1 empty dialog, I get the following 2 errors: Compiling......
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.