1

The following application gives me an access violation on its first line, whats with that?

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

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

using namespace xercesc;

int main()
{

    XMLCh* path= XMLString::transcode("test.xml"); 

    return 0;
}

[edit] 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;
}
Gungho
  • 42
  • 1
  • 6

1 Answers1

1

The obvious error in your program is that you are not initializing xerces-c before using it.

http://xerces.apache.org/xerces-c/program-2.html

You must call XMLPlatformUtils::Initialize() before making any other calls to xerces-c.

CB Bailey
  • 755,051
  • 104
  • 632
  • 656
  • Thanks very much Charles, perhaps you would be kind enough to help me with one further query, i have updated my original question with my new problem. Thanks – Gungho Jun 21 '10 at 16:44
  • @Tim: As you've already accepted an answer to this question and your new question is substantively different from the original wording, it would make more sense to ask it as a new question. – CB Bailey Jun 21 '10 at 17:22
  • i have asked a new question here http://stackoverflow.com/questions/3091484/exception-in-two-line-xerces-program – Gungho Jun 22 '10 at 08:34