Re: [xml] A question about parsing/reading DOCTYPE nodes.

On Mon, Nov 28, 2011 at 03:58:56PM +0100, Alexander Hugestrand wrote:

I've had the following problem in both PHP and C++, and can't find
any relevant information about this. It should be quite simple

I am trying to parse an xml file, and my code works perfectly for
all node types except DOCTYPE nodes. But I can't find any
information about how to extract the information from it. Here is an
example (my goal is to retrieve the strings "PublicIdentifier" and

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE test PUBLIC "PublicIdentifier" "URIreference">

Here is some code that illustrates my approach, using an

*while*(xmlTextReaderRead(myXmlReader) == 1) {
// Why does xmlTextReaderNodeType() return an int and not an enum?
        xmlReaderTypes nodeType =
*switch*(nodeType) {
*case *XML_READER_TYPE_ELEMENT: /* Do something */ *break*;
*case *XML_READER_TYPE_END_ELEMENT: /* Do something */ *break*;
*case *XML_READER_TYPE_TEXT: /* Do something */ *break*;
*case *XML_READER_TYPE_CDATA: /* Do something */ *break*;
*case *XML_READER_TYPE_PROCESSING_INSTRUCTION: /* Do something */ *break*;
*case *XML_READER_TYPE_COMMENT: /* Do something */ *break*;
            // ...
// What do I do here?

  Get the underlying xmlNodePtr
make sure it's type is XML_DTD_NODE, and then cast it to a
xmlDtdPtr, then look at SystemID and ExternalID fields,


Daniel Veillard      | libxml Gnome XML XSLT toolkit
daniel veillard com  | Rpmfind RPM search engine | virtualization library

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