[xml] XmlSaveToBuffer - how to use it to save an XmlDoc out to a buffer?



Title: XmlSaveToBuffer  - how to use it to save an XmlDoc  out to a buffer?

Hi,

I currently use the following to read in an html file then save it to a buffer.
 
 
XmlDocPtr doc=htmlReadMemory([xhtmlAsDatabytes],[xhtmlAsDatalength],"",NULL,
 HTML_PARSE_NOWARNING | HTML_PARSE_NOERROR)
 
 Then I do a bunch of changes to doc and save it to a buffer using:
 
 xmlDocDumpFormatMemory(doc, &xmlbuff, &buffersize, 1);
 
 
THAT WORKS GREAT! Except! I don't get both start and end tag. For example if the original html has
<noscript></noscript>
 
The  dumped document will have just
<noscript/>
 
Which, although that’s legal, its not what I want. I want both the start and end tags to be printed.
 
 Daniel suggested using the   XML_SAVE_NO_EMPTY flag... But how?  And when? Do I  use  
 
xmlSaveToBuffer instead of xmlDocDumpFormatMemory????  I tried the following and it didn't work...
 
 XmlDocPtr doc=htmlReadMemory([xhtmlAsDatabytes],[xhtmlAsDatalength],"",NULL,
 HTML_PARSE_NOWARNING | HTML_PARSE_NOERROR)
 
 ...do a bunch of changes to doc...
 
 xmlbuffNew = xmlBufferCreate();
 xmlSaveToBuffer(xmlbuffNew, NULL, XML_SAVE_NO_EMPTY);
 
 
 Basically how do I dump the document out to a buffer with start and end tags included? Any help would be greatly appreciated!



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