You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xerces.apache.org by "KRAUSE,MIKE (HP-FtCollins,ex1)" <mi...@hp.com> on 2000/03/08 23:59:22 UTC

Getting DOCTYPE from xml file

Hi,

I'm using the DOMPrint example as the basis for a SaveFile function I'm
writing.  One problem I'm encountering is that the DOMPrint example does not
print the <!DOCTYPE ...> declaration in my XML file.

If I have the following sample XML file...

<?xml version="1.0" standalone="no"?>
<!DOCTYPE foo SYSTEM "foo.dtd">
<foo>
...
</foo>

And the following code... (assume that doc is a valid DOM_Document node
returned from the parser and that it refers to the aforementioned file)

void somefunc(DOM_Document &doc) {
   DOM_DocumentType docType = doc.getDoctype();
   DOMString dtdName = docType.getName();
}

Why is it that if I call the DOM_Document's getDoctype() method I get a null
DOM_DocumentType node?  Should I be doing something else in order to print
out the "<!DOCTYPE foo SYSTEM "foo.dtd">" line?

One last thing...  how do I output the first line of my XML document
verbatim?

Regards,

Mike Krause
Hewlett-Packard Company