[xml] How to create an ISO-8859-1 encoded xml file?



Hi,

actually I'm tring to produce a XML-file using libxml2-2.3.5:

<?xml version="1.0" encoding="ISO-8859-1"?>
<info>abc</info>


I wrote the following code for this job:

void DoIt(void)
{
  xmlDocPtr doc;
  xmlNodePtr n;

  doc = xmlNewDoc("1.0");
  n = xmlNewNode(NULL, "info");
  xmlNodeSetContent(n, "abc");
  xmlDocSetRootElement(doc, n);
  xmlSaveFileEnc("test.xml",doc,"ISO-8859-1");
  xmlFreeDoc(*pDoc);
}

But the result ist a runtime-error message:
"xmlSaveFileEnc: document not in UTF8 "

Why this? I think, all charactars are hold internally as UTF8?

Therefore my 1. question:
How to modify the code to get my "encoding=..." headline?

2. question:
What to do to insert german characters in the output (to get the following 
result):
<?xml version="1.0" encoding="ISO-8859-1"?>
<info>äüö</info>

Thanks a lot for every advise


  Mark






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