[xml] problem reading attributes in XML with DTD
- From: oliverst online de
- To: <xml gnome org>
- Subject: [xml] problem reading attributes in XML with DTD
- Date: Wed, 19 Oct 2005 14:28:33 +0200
I am trying to read the attributes in an XML with a DTD (http://www.breaken.de/temp/output.xml) and for soem
reason I don't get the attributes with the node with xmlGetProp(). I read in the manual, that it does look
for the #FIXED or default declarations unless DTD validation has been turned off. I have no DTD validation
activated (I assume passing 0 as the last parameter in xmlReadFile() truns it off) and I don't get anything
from xmlGetProp(). If I look at the properties, I can clearly, that the first one is the one I am looking for
("name"). If I remove the DTD part in the XML it does parse it fine, but I don't want to remove, as this XML
is automatically created.
I have absolutely no experience with DTDs, so I am quite lost right now.
I am using libxml2-2.6.22 on Windows 2000 with MinGW (GCC 3.4.4) configured with
cscript configure.js xml_debug=no debug=no mem_debug=no static=yes iconv=no schemas=yes regexps=yes docb=no
threads=native ftp=no http=no reader=no walker=no legacy=no xpath=yes xptr=no catalog=no xinclude=no c14n=no
writer=no walker=no push=no pattern=yes schematron=no modules=no compiler=mingw
Here is the code I am using. The xmlGetProp() calls return NULL.
void parse_mame_xml(const char* filename)
{
xmlDocPtr doc = xmlReadFile(filename, NULL, 0);
if( doc ) {
xmlNodePtr root = doc->children;
if( root ) {
xmlNodePtr game_child = root->children;
while( game_child ) {
if( xmlStrcmp(game_child->name, (const xmlChar*)"game") == 0) {
xmlChar* game_name = xmlGetProp(game_child, (const xmlChar*)"name");
if( game_name ) {
printf("name: %s\n", (const char*)game_name);
xmlFree(game_name);
}
xmlChar* game_src = xmlGetProp(game_child, (const
xmlChar*)"sourcefile");
if( game_src ) {
printf("sourcefile: %s\n", (const char*)game_src);
xmlFree(game_src);
}
xmlNodePtr game_children = game_child->children;
while( game_children ) {
if( xmlStrcmp(game_children->name, (const xmlChar*)"driver")
== 0 ) {
xmlChar* game_status = xmlGetProp(game_children,
(const xmlChar*)"status");
if( game_status ) {
printf("status: %s\n", (const
char*)game_status);
xmlFree(game_status);
}
break;
}
game_children = game_children->next;
}
}
game_child = game_child->next;
}
}
xmlFreeDoc(doc);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]