From: Christophe de V. <cde...@al...> - 2003-12-16 10:33:34
|
Hi, Bastian_Pfennigschmidt/CODESCO/DE...@co... wrote: > > Hello, > > I've tried to read and write an XML file using your great library - > but I'm running into some problems, > it would be very nice, if you could give me some code snippets. > Did you have a look to the examples ? If you think something important is missing in it, just tell us. > Here are my problems: > > 1. When I create an XML using write_to_string or write_to_file and > there are special characters, like > German umlauts, they are not converted into entities. The XML file is > UTF-8 encoded. > > mXMLParser->get_document()->write_to_string("UTF-8"); > > When I try to parse the output, I got a parsing error, because the > special characters are not valid in UTF-8. > Don't forget that in-memory libxml++ encoding is supposed to be UTF-8. Any call to a function of the API is waiting for UTF-8 encoded strings. So if you gave it ISO-xxx encoded string with special characters this probably led to your problem. > > And my second problem: > > I'm using write_to_file_formatted to get a formated file. If I use > write_to_file I get a document with only to lines. > But if I parse this formatted file again and write it back to file, > the formatting are gone (see my attachment). > The formatting was gone with write_to_file_formatted ? Or did you use write_to_file the second time ? > > > Many thanks for your help > Your welcome. BTW please use the mailing list next time you need help. Cheers, Christophe |
From: Christophe de V. <cde...@al...> - 2003-12-16 11:11:58
|
Bastian_Pfennigschmidt/CODESCO/DE...@co... wrote: > Encoding problem: I thought that the libxml encodes all special > characters to entities if I write it to xml, but it seems to be that > I'm responsible to do that - ok! > Yes you are. The easier is to use iconv (which I personnaly wrap into a c++ class, making it even easier to use). > Formatting problem: > > Yes, I'm using write_to_file_formatted every time, it's the same with > write_to_string_formatted, the formatting was gone after > parsing and writing the second time. > I cannot reproduce this. Please provide an example. What version of libxml++ and libxml2 do you use ? Christophe |
From: Christophe de V. <cde...@al...> - 2003-12-16 12:59:32
|
Hi In the code you sent I see only calls to write_to_string, no write_to_string_formatted at all. So understanding the formatting problem is a bit difficult :-) It would be better if you could reproduce the problem in a small program, possibly based on dom_read_write example. Regards, Christophe Bastian_Pfennigschmidt/CODESCO/DE...@co... wrote: > > Here's my class in which I use the libxml++ > Have a look at XMLInit and XMLDeinit > > I've updated to the newest available versions of libxml++ and libxml2. > > It's compiled as stdcall 2Byte - because of the application in which I > use > the libxml++ > There are no problems with the libxml++ or libxml2 except this > formatting problem. > |
From: Christophe de V. <cde...@al...> - 2003-12-16 14:11:42
|
Bastian_Pfennigschmidt/CODESCO/DE...@co... wrote: > <snip> > > If I compile the dom_read_write example the output looks fine, even > when I use > write_to_file instead of write_to_file_formatted. > It's because formatting is done by inserting whitespaces that are kept as text nodes when parsing. So writing it again keep the formatting. > > Something get wrong - maybe there are some conflicts with my other > libraries. Do you have other parts of your program using libxml2 without libxml++ ? Normaly it shouldn't alterate the behavior of libxml++ with formatting but we never know : some settings for formatting are global one and I could have missed one when saving the context before the effective writing. When you lose the formatting of the output, is everything on a single line or two, or is it just messed up ? > So, I think there is no way to get a clean formatted xml output with > my project settings. > > > Thanks for help Your welcome Christophe |
From: Christophe de V. <cde...@al...> - 2003-12-16 15:14:43
|
Bastian_Pfennigschmidt/CODESCO/DE...@co... wrote: > > My application is a kind of plugin for another program, its linked as > a dll. > I have to link against six other libraries. > In my code I only use the libxml++. > > > If I use write_to_string without formatting I got the output in two > lines, the first with the xml tag <?xml ... ?> > and the rest of the file as a singe line in the second line of the file. > > xmlDocument.write_to_file("without_formatting.xml", "UTF-8"); > xmlDocument.write_to_file_formatted("with_formatting.xml, "UTF-8"); > > (see attachments) > > > Now the formatting is right in with_formatting.xml, but if I parsed it > again and save it, you got a document > like the one I've attached to my second mail. > Strange. It looks a bit like if you modified the tree and saved it with write_to_file : some formatting whitespaces are still there, some other not at all. Let me know if you solve the problem and what was the reason. Regards, Christophe |