Reputation: 51
I have a problem of parsing my xml file, it is not correct with libxml but it's certified valid by the owner of application.
I have tried to read the RFC to XOP but seems don't related with my problem. And i don't understand how to implement others solutions in my code.
int main(int argc, char **argv) {
char *docname;
xmlDocPtr doc;
xmlNodePtr cur;
xmlChar *date;
if (argc < 2) {
printf("Commande: %s nom_du_fichier\n", argv[0]);
return EXIT_FAILURE;
}
docname = argv[1];
doc = xmlParseFile(docname);
cur = xmlDocGetRootElement(doc);
cur = cur->xmlChildrenNode;
while (cur != NULL) {
if ((!xmlStrcmp(cur->name, (const xmlChar *)"anpr"))) {
date = xmlGetProp(cur, "date");
printf("date: %s\n", date);
xmlFree(date);
}
cur = cur->next;
}
xmlFreeDoc(doc);
return EXIT_SUCCESS;
}
Code xml:
<msg><tag date="1556896362471" session="1702"><jpeg><xop:Include href="A"/></jpeg>/msg>
file.xml:1: namespace error : Namespace prefix xop on Include is not defined
This tag has not useful but i can't remove manually each time.
Upvotes: 0
Views: 485
Reputation: 1762
I have a problem of parsing my xml file, it is not correct with libxml but it's certified valid by the owner of application.
If the XML file is exactly as it appears in your question, then the owner of the application is wrong. Any conformant XML parser will encounter a fatal error trying to parse that XML.
I have tried to read the RFC to XOP but seems don't related with my problem.
You're correct, the details of XOP are unrelated to this lower-level problem.
It may be worth learning the basics XML Namespaces, so you can better understand why that XML is not well-formed (specifically the xmlns
attribute). https://www.w3schools.com/xml/xml_namespaces.asp
Upvotes: 1