473,699 Members | 2,096 Online
Bytes | Software Development & Data Engineering Community
+ 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\Visua l Studio
Projects\Q81565 8XMLRead\Q81565 8XMLRead.cpp(13 ): error C2144: syntax error :
'int' should be preceded by ';'
c:\Documents and Settings\Scott H. Chang\My Documents\Visua l Studio
Projects\Q81565 8XMLRead\Q81565 8XMLRead.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::El ement: // The node is an element.
Console::Write( "<{0}", reader->Name);

while (reader->MoveToNextAttr ibute()) // Read the attributes.
Console::Write( " {0}='{1}'", reader->Name, reader->Value);
Console::WriteL ine(">");
break;
case XmlNodeType::Te xt: //Display the text in each element.
Console::WriteL ine (reader->Value);
break;
case XmlNodeType::En dElement: //Display the end of the element.
Console::Write( "</{0}", reader->Name);
Console::WriteL ine(">");
break;
}
}
Console::ReadLi ne();
}

Nov 12 '05 #1
2 2774


SHC wrote:

I
got the following 2 errors:
c:\Documents and Settings\Scott H. Chang\My Documents\Visua l Studio
Projects\Q81565 8XMLRead\Q81565 8XMLRead.cpp(13 ): error C2144: syntax error :
'int' should be preceded by ';'
c:\Documents and Settings\Scott H. Chang\My Documents\Visua l Studio
Projects\Q81565 8XMLRead\Q81565 8XMLRead.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.Xml Exception'
occured
in system.xml.dll
Addtional Information: System error
|Break| |Continue|
I clicked on the |Continue| and I got the following:
"c:\Documen ts and Settings\Scott H. Chang\My Documents\Visua l Studio
Projects\Q81565 8XMLRead....... ..
unhandled Excetion: System.Xml.XmlE xception:
The XML declaration is unexpected.
Line 1, position 4
at System.Xml.XmlT extReader.Parse Tag<>
at System.Xml.XmlT extReader.Parse Root<>
at System.Xml.XmlT extReaderRead<>
at main (Int32argc, SByte ** argv) in
c:\documents and
settings\.....\ .....\q815658xm lread\q815658xm l.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
2768
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 errors: E:\CODE\VariableRating.cpp(712) : error C2146: syntax error : missing ';' before identifier 'SQL' E:\CODE\VariableRating.cpp(712) : error C2501: 'EXEC' : missing storage-class or type specifiers
0
6125
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 file as folows. I need help to resolve them ASAP: cl /c /nologo /MDd /W3 /Od /GR /GM /Zi /GX /D "_DEBUG" /D " WIN32" /D "_W INDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /D "_USRDLL" /
11
12474
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 also the headers. Those errors do NOT make any sense at all. THANKS and regards Michael warning C4067: unexpected tokens following preprocessor directive -
1
2250
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 '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...
6
2742
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 2003 - Windows XP Pro PC suscessfully. But when I ran it from the command line - C:\Documents and Settings\SHC\My Documents\Visual Studio Projects\XMLdtdValidatingReader\Debug>XMLdtdValidatingReader valcanoes.xml, I got the following message in...
0
3641
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 for VC++ application project // generated using an Application Wizard. #include "stdafx.h" #include <stdlib.h>
1
1634
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 Studio .NET 2003\Vc7 \include\xdebug(34) : fatal error C1004: unexpected end of file found I cannot understand what is wrong.
2
5737
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 in debug mode, the following errors happened: d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xdebug(29): error C2365: 'new' : redefinition; previous definition was a 'member function' d:\Program Files\Microsoft Visual Studio...
1
4322
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... stdafx.cpp c:\program files\microsoft visual studio 8\vc\include\excpt.h(33) : error C2144: syntax error : 'int' should be preceded by ';' c:\program files\microsoft visual studio 8\vc\include\excpt.h(33) : error C4430: missing type specifier - int...
0
8691
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8620
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8920
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7755
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4378
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4633
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3060
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 we have to send another system
3
2012
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.