Thanks

On Sun, Aug 3, 2008 at 3:40 AM, David Bertoni <[EMAIL PROTECTED]> wrote:

> Daniel Burrell wrote:
>
>> Hey,
>> What would be the best way to add a doctype declaration tag to a document
>> that doesn't have one?
>>
>> I've tried this, but it doesn't work, gives some sort of unhandled error:
>>
> Why don't you use a try/catch block to catch the DOMException and get the
> error code?  Or better yet, you can debug into the call and see what's
> happening.
>
>
>> DOMNode  *theRootNode;
>>        theRootNode = //somehow find the node we should insert before, how
>> do i find this node?
>>        DOMNode  *theDocTypeNode;
>>        theDocTypeNode = doc->createDocumentType(XMLString::transcode(
>> "collection" ), 0, XMLString::transcode( gDtdFile ))        ;
>>        doc->insertBefore(theDocTypeNode,theRootNode);
>>
> These calls to XMLString::transcode() return pointers that you need to
> deallocate.  See the documentation for XMLString::transcode() for more
> information.  Also, what is the value of theRootNode?  Your comment seems to
> indicate that you don't know what child to use.  I would recommend you use
> the document element by calling DOMDocument::getDocumentElement().
>
> I pasted the following code into the CreateDOMDocument sample at line 148:
>
> DOMNode  *theDocTypeNode =
>     theDocTypeNode = doc->createDocumentType(
>                            XMLString::transcode("collection" ),
>                            0,
>                            XMLString::transcode( "foo.dtd"));
> doc->insertBefore(theDocTypeNode,rootElem);
>
> which worked correctly.
>
>
>> Also, is there an 'insertAfter' function?
>>
> No.
>
> Dave
>

Reply via email to