Hi,
When I open a file for the second time (sequentially) i get the error
error: junk after document element
tA one-time opening and use of the file works fine, it's the second time
where something goes wrong. The code basically looks like this:
ifstream in(path.c_str());
assert(in);
string line;
while (getline(in, line))
{
// do stuff
};
// in.clear();
// in.close();
I have used in.clear() and closed() with no success... If i call the loading
routine the second time, i get the error. Does anyone have any ideas what
the trouble might be? 2 2415
Jeremy Bishop wrote: Hi,
When I open a file for the second time (sequentially) i get the error error: junk after document element
tA one-time opening and use of the file works fine, it's the second time where something goes wrong. The code basically looks like this:
please post the exact code.
Strip all unneccessary and not related stuff. It would be ideal, if you
could come up with a small, complete, compilable program which demonstrates
your problem.
ifstream in(path.c_str());
assert(in);
string line;
while (getline(in, line))
{
// do stuff
};
// in.clear();
// in.close();
I have used in.clear() and closed() with no success... If i call the loading routine the second time,
From this I conclude that the above is in a function, which is
called 2 times. The first time it works, the second time it doesn't?
Correct ?
i get the error.
which error?
Where is the error detected? I can't see anythting in you 'code' above.
Does anyone have any ideas what the trouble might be?
--
Karl Heinz Buchegger kb******@gascad.at
try using
ifstream( path.c_str(), ios::in, filebuf::sh_read );
I have not tried it but the documentation says that this allows file
sharing.
Karl Heinz Buchegger wrote: Jeremy Bishop wrote:
Hi,
When I open a file for the second time (sequentially) i get the error error: junk after document element
tA one-time opening and use of the file works fine, it's the second time where something goes wrong. The code basically looks like this:
please post the exact code. Strip all unneccessary and not related stuff. It would be ideal, if you could come up with a small, complete, compilable program which demonstrates your problem.
ifstream in(path.c_str());
assert(in);
string line;
while (getline(in, line))
{
// do stuff
};
// in.clear();
// in.close();
I have used in.clear() and closed() with no success... If i call the loading routine the second time,
From this I conclude that the above is in a function, which is called 2 times. The first time it works, the second time it doesn't? Correct ?
i get the error.
which error? Where is the error detected? I can't see anythting in you 'code' above.
Does anyone have any ideas what the trouble might be? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jennifer Smith |
last post by:
Currently we have a site that allows users to listen to mp3 files. It
is creating bandwidth issues. So we want to move the mp3 files to an
ISP that caps bandwidth usage. Ours is currently...
|
by: Jason Heyes |
last post by:
I would like to modify the contents of a file, replacing all occurances of
one string with another. I wrote these functions:
bool read_file(std::string name, std::string &s);
bool...
|
by: W. Van Hooste |
last post by:
Just starting with C, can somebody explain why this does not work or
point me in the right direction? I wrote some tools and did some
coding but cant seem to get this one. I DID declare my FILE...
|
by: noleander |
last post by:
I've got two threads reading from one disk file (I'm using the Pthread
library).
I need each thread to have its own file seek pointer, so they can read from
independent parts of the file.
I...
|
by: theyas |
last post by:
How can I get my code to NOT display two "Open/Save/Cancel/More Info" dialog boxes when using the "Response.WriteFile" method to download a file to IE
I've asked about this before and didn't get a...
| |
by: AFN |
last post by:
I was just dropped into someone else's code (isn't that always so fun?).
I can't figure out why a custom validation control's server event function
is executing. There is nothing (that I see)...
|
by: John Regan |
last post by:
Hello All
I am trying to find the owner of a file or folder on our network (Windows
2000 Server) using VB.Net and/or API. so I can search for Folders that don't
follow our company's specified...
|
by: Mark Ingram |
last post by:
Hi, i want to ensure that an xml file has been created properly, but i
dont want to rely on the creator of the xml file to correctly enter the
required namespaces (without the correct namespaces...
|
by: Amir Michail |
last post by:
Hi,
Trying to open a file for writing that is already open for writing
should result in an exception.
It's all too easy to accidentally open a shelve for writing twice and
this can lead to...
|
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,...
|
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...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
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...
|
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,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
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: 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...
| |