[xml] parsing a DTD to get elements and attributes



Hello,

I want to parse a simple, self-made DTD to get the
elements and the attributes I´ve defined there.

I understand that I have to use xmlParseDTD() but don´t know
which functions to use to get all elements with their
attributes.


Regards,
Andy

-------------------------------------------------------------
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include <libxml/xmlmemory.h>
#include <libxml/parser.h>

#define DEBUG(x) printf(x)

int main (int argc, char **argv)
{
    xmlDtdPtr dtd;
    xmlNodePtr cur;

    /* make sure args were specified */
    if (argc != 2)
    {
       xmlGenericError(xmlGenericErrorContext,
                       "usage: scan_dtd <DTD_file>\n");
       exit(2);
    }

    dtd = xmlParseDTD(NULL, (const xmlChar *) argv[1]);
    if (dtd == NULL) {
       xmlGenericError(xmlGenericErrorContext,
                       "Could not parse DTD %s\n", argv[1]);
       exit(2);
     }
     else
     {
        // what can I do now with dtd?
     }
     xmlCleanupParser();
     exit(0);
}





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