Re: [xml] (Windows) xmlDocDump / xmlSavefile



Hi again,

Thanks for the code below. I have used the same function that you have demonstrated below and followed it 
diligently. And now I can see the text inside he xml file. 

Thanks for your help.

Regards

Xen 
PS!! Are you using gcc by any chance and do you use linux?



-----Original Message-----
From: Trappel Martin [mailto:martin trappel ksengineers at] 
Sent: 11 May 2007 11:07
To: Xen Cloete
Cc: xml gnome org
Subject: 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
 



"Hollard is a licensed Financial Services Provider (FSP) as defined in the Financial Advisory and 
Intermediary Services Act (FAIS). FAIS requires that anyone who makes any recommendation, guidance or 
proposal of a financial nature must be a duly authorised representative of a licensed FSP. If you are seeking 
financial advice, or if you feel that this email constitutes financial advice, or if the author of this email 
wants you to purchase, amend or cancel a policy, please check with the author that he/she is a registered 
representative of Hollard." 
This email and all content are subject to the following disclaimer:

"http://www.hollard.co.za/legal/disclaimer.htm"; 





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