Hello!

I'm using this code to parse an in memory XML:

[...]
    xmlParserCtxtPtr context = xmlNewParserCtxt();
    if (!context)
    {
        error = "Failed to allocate parser context";
        return;
    }
    xmlDocPtr doc = xmlCtxtReadMemory(
        context, xml, xml_size, NULL, NULL, 0);
    if (!doc && context->lastError.message)
        error = context->lastError.message;
[...]

When I parse the following invalid document:

<presence xmlns="urn:ietf:params:xml:ns:pidf" entity="sip:[email protected]">
    <tuple id="t1">
        <status>
            <basic>open</basic>
        </status>
</presence>

the error from context->lastError is
"Premature end of data in tag presence line 1"
but the one displayed on the screen is:

Entity: line 6: parser error : Opening and ending tag mismatch: tuple line 2 
and presence
</presence>
           ^
Entity: line 8: parser error : Premature end of data in tag presence line 1

Why doesn't the parser stop after first error is found?
How can I obtain the first error generated by the parser because it is more 
suggestive to
report to a user?

Thank you,
Tiberius
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml

Reply via email to