[xml] Parse unavailable document



Hello,

Using libxml2-2.6.0 on Windows. Suppose that "systemId" contains an unavalible URL, then 

inputStream = xmlLoadExternalEntity(systemId, NULL, ctxt);

will set "ctxt->lastError" to an I/O warning ("failed to load external entity ...").

However, if I use

xmlDocPtr doc = xmlCtxtReadFile(ctxt, systemId, NULL, 0);

I get a :
- NULL doc,
- "ctxt->input" is NULL 
- but "ctxt->lastError->level" is set to "XML_ERR_NONE". 

1) Why "xmlCtxtReadFile" doesn't raise an I/O warning ?

2) If "xmlCtxtReadFile" returns a NULL doc and I want to check if the URL is not valid, is enough to check if 
"ctxt->input" is NULL or should I call "xmlLoadExternalEntity" and get the I/O warning to be sure that the 
problem is that?

Best regards,
Manuel




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]