Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 860895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:53:22+00:00 2026-05-15T08:53:22+00:00

The following code gives me an exception on the XMLFormatTarget line, but if I

  • 0

The following code gives me an exception on the XMLFormatTarget line, but if I change the string from "C:/test.xml" to "test.xml" it works fine.

// test.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/framework/LocalFileFormatTarget.hpp>

using namespace xercesc;

int main()
{
    XMLPlatformUtils::Initialize();

    XMLFormatTarget *formatTarget = new LocalFileFormatTarget("C:/test.xml"); 

    return 0;
}

[edit]
Xerces exception is:

Error Message: unable to open file
‘C:\test.xml’

Windows exception is:

Access is denied

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T08:53:23+00:00Added an answer on May 15, 2026 at 8:53 am

    It could be that you don’t have sufficient permissions to write to C:\. In such a case, Xerces might report the error throwing an exception.

    An Access Denied exception is typically what we could expect if you try to write to a system directory without administrator credentials.


    Maybe it has also something to do with the directory separators:

    XMLFormatTarget *formatTarget = new LocalFileFormatTarget("C:\\test.xml");
    

    On Windows, directory separators are backslashes “\”. Some libraries don’t care (and I never used Xerces, so I can’t tell). In C and C++, backslash is also an escape character and so you must double it if you want a litteral “\” in your string.

    Also, telling us what was the exception you got would help us even more.


    Not directly related, but from your code, it seems you never delete formatTarget. I assume this is sample code, but if it is not, you should add the following line to your code:

    delete formatTarget;
    

    Or use a scoped pointer instead:

    boost::scoped_ptr<XMLFormatTarget> formatTarget(new LocalFileFormatTarget("C:\\test.xml"));
    

    To avoid memory leaks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Executing the below code gives me the following exception on the last line: InvalidOperationException:
The following line of code gives an exception. Is this a bug in the
The following code gives a segmentation fault on the last line require 'rubygems' gem
Using the following code I get a nice formatted string: Request.QueryString.ToString Gives me something
In the following code, g++ gives this error : 1.cpp: In member function void
I have the following code which fetches a string from an array of strings
The following code gives me a really weird error in Firefox: Error: uncaught exception:
I have the following WPF code and it gives me an exception at TextBox
I am using the following code. When i change orientation from portrait to landscape,
i want create XML file here is my following code String fileName = jasstech.xml;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.