Re: [xml] (Windows) xmlDocDump / xmlSavefile



-----------------
From: Xen Cloete [mailto:XenC hollard co za] 
Sent: Friday, May 11, 2007 9:28 AM
Subject: RE: [xml] (Windows) xmlDocDump / xmlSavefile

Hi Trappel,
Thanks for you reply. 

Over and above the functions that I have used below, the xmlSaveFormatFile
was used as well. Unfortunately when I open the resultant file I see binary
only. I would like to see the text instead. 

Are there any prior settings that need to take place i.e. this is what I
have done below and found this still to be a problem.

xmlSetCompressMode(0); // no compression, maybe this has no relebance
xmlKeepBlanksDefault(0);

xmlSaveFormatFile(path, doc, 1); // this file does not display the xml in
text as I want it to be L


Thanks

Regards
Xen 
-----------------------
 

I use xmlSaveFormatFileEnc(..) without probblems, and it certainly has never
written something looking binary for me.

**********************
// libxml2console.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include <libxml/encoding.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/xpath.h>

#include <string>

using namespace std;

//////////////////////////////////////////////////////////////////////
// Encoding defines:
#define XML_ENCODING_UTF8 "UTF-8"

//////////////////////////////////////////////////////////////////////
// Cast defines:
#define XMLCHARCAST(x) reinterpret_cast<const xmlChar*>(x)
#define STDCHARCAST(x) reinterpret_cast<const char*>(x)


int _tmain(int argc, _TCHAR* argv[])
{
        xmlInitParser();
        
        const char* fname = "c:\\temp\\libxml2test.xml";
        
        xmlDocPtr doc = xmlReadFile(fname, NULL, XML_PARSE_NOBLANKS);
        xmlNodePtr root_element = xmlDocGetRootElement(doc);
        if(XML_ELEMENT_NODE == root_element->type) {
                xmlAttrPtr newAttr1 = xmlSetProp(root_element,
XMLCHARCAST("attrname"), XMLCHARCAST("attrvalue"));
        }
        xmlSaveFile(fname, doc);
        xmlCleanupParser();
        return 0;
}
***********************************


best regards / mit freundlichen Grüßen,
Martin Trappel
 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]