PugiXML error - status_end_element_mismatch

1k views Asked by At

I am using pugiXML in one of my examples(Android with JNI) and I am trying to parse an XML file that is written is Chinese or Japanese for example and I always get

  • case status_end_element_mismatch: return "Start-end tags mismatch"; almost always on some random line near or at the end of a XML file.

  • I get the parse result with

pugi::xml_document doc; pugi::xml_parse_result result = doc.load(File._Buffer); if (result){ __android_log_print(ANDROID_LOG_INFO, "MyExample", "XML [ %s ] ;parsed without errors, attr value:[ %s ] ",File._Buffer , doc.child("node").attribute("attr").value()); else { __android_log_print(ANDROID_LOG_INFO, "MyExample", "Error description: %s" , result.description()); __android_log_print(ANDROID_LOG_INFO, "MyExample", "Error offset: %ul" , result.offset); }

My English language XML works just fine.

I have checked the XML file with various validators and even "by hand - line by line" and it is not missing any tags and all validators confirm that it is a valid XML file.

My file is not any bigger than 1 mg. I have read that people used with success pugiXML with over 9 mg files so it can`t be a memory issue.

Did anyone had this kind of problems? If somebody have some pointers?

Thank you.

1

There are 1 answers

0
Adrian Ivasku On

After careful analysis the problem was in the information while opening the file. Since I was reading multiple XML files I simply read the WRONG file`s size which was smaller than the original file I was trying to read.

The pugiXML read the file with a size from another(smaller) file and while reading it, the file was truncated and the end parent tag simply did`t close the line - therefore Pugixml reported the error "Start-end tags mismatch".

When given the right size, the xml parsing works excellent. I want to thank Zeuxcg for huge help on this matter! Thank you for helping me.