Michel Morgan wrote:
I am a beginner and started to use xerces-c-src_2_8_0 with C++ in
VisualStudio 2005
I have the following code which is supposed to read Test1.txt then dump
it to Test2.txt
Content of Test1.txt is listed under the code.
The problem is, when I open output file "Test2.txt" using "notepad" I
see all lines combined such as
<?xml version="1.0" encoding="UTF-8" standalone="no" ?> [] [] <Items> []
<Item a="1"> [] </Item> [] </Items> [] []
Am I doing somthing wrong? I wish to be able to split these into several
lines
Thanks for your help
code
----
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/sax/HandlerBase.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/framework/LocalFileFormatTarget.hpp>
XERCES_CPP_NAMESPACE_USE
int main(int argc, char *argv[])
{
XMLPlatformUtils::Initialize();
XercesDOMParser* parser= new XercesDOMParser();
parser->parse("Test1.txt");
DOMDocument* MyDoc=parser->getDocument();
DOMImplementation *impl =MyDoc->getImplementation();
DOMWriter *theSerializer =impl->createDOMWriter();
theSerializer->setNewLine(XMLString::transcode("\n\r") );
This is a memory leak. You need to free the pointer return by the
transcode function:
XMLCh* lfSeq = XMLString::transcode("\r\n");
theSerialize->setNewLine(lfSeq);
XMLString::release(&lfSeq);
Also, the DOS sequence is CR/LF, so you want "\r\n" instead of "\n\r".
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]