Re: [xml] How to add a DTD to a document



On Sun, Mar 09, 2014 at 02:46:35PM +0100, Nick Wellnhofer wrote:
On 3/9/2014 17:33, Nick Wellnhofer wrote:
I can’t find out how to add a DTD (internal subset) to a document without poking into libxml2’s internal 
data structures. The obvious approach is to add a xmlDtdPtr using
xmlAddPrevSibling on the document root. But this will cause a memory leak because xmlFreeDoc won’t free 
the DTD nodes. It only frees the DTDs pointed to by doc->intSubset and doc->extSubset. So do I have to 
deal with these struct members manually or is there a better way?

xmlCreateIntSubset() ? But it looks like you'll need to manually free previous xmlDtd first.

Suppose that I already have a xmlDtdPtr, for example from another document. This question came up when 
trying to correctly implement the “replaceNode” method in the Perl bindings.

  I'm afraid you have to access the structure indeed (it's part of the
API/ABI)

Daniel

-- 
Daniel Veillard      | Open Source and Standards, Red Hat
veillard redhat com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | virtualization library  http://libvirt.org/


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