Hello,
after days of trying, I have not got any valuable solution for the
following problem:
I try to retrieve the attribute id from a node, which breaks, because a
comparison between the node's name and a string fails (though the string
is correct and should be found by the function).
The xml file looks like this:
<?xml version="1.0"?>
<!DOCTYPE lingoteach SYSTEM
"/usr/local/src/marcus/devel/lingoteach/data/lingoteach.dtd">
<lingoteach>
<meaning id="m0">
<translation language="english">test</translation>
<translation language="spanish">test</translation>
</meaning>
</lingoteach>
The id-attribute from the <meaning> should be retrieved using this
function:
int
_data_meaning_get_max_word_id (xmlDocPtr lesson)
{
xmlNodePtr node_ptr;
char* tmp;
lesson->parent = xmlDocGetRootElement (lesson);
if (lesson->parent->name == NULL
|| strncmp (lesson->parent->name, "lingoteach", 1) != 0)
{
printf (_("Error: Rootnode does not seem to be correct, "
"abort while getting the max. id...\n"));
return NULL;
}
if ((node_ptr = lesson->parent->children) == NULL
|| node_ptr->name == NULL
|| strncmp (node_ptr->name, "meaning", 7) != 0)
{
printf (_("Could not verify correct node name in your "
"user specific lesson, aborting...\n"));
return NULL;
}
node_ptr = xmlGetLastChild (lesson->parent);
tmp = xmlGetProp (node_ptr, "id");
tmp = strtok (tmp, "m");
return atoi(tmp);
}
The function breaks while doing the strncmp on the node_ptr.
After taking a closer look at it, the name, which is given back by the
node, is "text", not "meaning".
What am I doing wrong?
Thanks in advance and regards
Marcus
--
Mr. Cole's Axiom:
The sum of the intelligence on the planet is a constant; the
population is growing.
Attachment:
pgpkzkHk6HQgX.pgp
Description: PGP signature