* xmlCtxtParseDocument: * @ctxt: an XML parser context * @input: parser input * * Parse an XML document and return the resulting document tree. * Takes ownership of the input object. * * Available since 2.13.0. * * Returns the resulting document tree or NULL */
| 13784 | * Returns the resulting document tree or NULL |
| 13785 | */ |
| 13786 | xmlDocPtr |
| 13787 | xmlCtxtParseDocument(xmlParserCtxtPtr ctxt, xmlParserInputPtr input) |
| 13788 | { |
| 13789 | xmlDocPtr ret = NULL; |
| 13790 | |
| 13791 | if ((ctxt == NULL) || (input == NULL)) |
| 13792 | return(NULL); |
| 13793 | |
| 13794 | /* assert(ctxt->inputNr == 0); */ |
| 13795 | while (ctxt->inputNr > 0) |
| 13796 | xmlFreeInputStream(inputPop(ctxt)); |
| 13797 | |
| 13798 | if (inputPush(ctxt, input) < 0) { |
| 13799 | xmlFreeInputStream(input); |
| 13800 | return(NULL); |
| 13801 | } |
| 13802 | |
| 13803 | xmlParseDocument(ctxt); |
| 13804 | |
| 13805 | if ((ctxt->wellFormed) || |
| 13806 | ((ctxt->recovery) && (ctxt->errNo != XML_ERR_NO_MEMORY))) { |
| 13807 | ret = ctxt->myDoc; |
| 13808 | } else { |
| 13809 | if (ctxt->errNo == XML_ERR_OK) |
| 13810 | xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR, "unknown error\n"); |
| 13811 | |
| 13812 | ret = NULL; |
| 13813 | xmlFreeDoc(ctxt->myDoc); |
| 13814 | } |
| 13815 | ctxt->myDoc = NULL; |
| 13816 | |
| 13817 | /* assert(ctxt->inputNr == 1); */ |
| 13818 | while (ctxt->inputNr > 0) |
| 13819 | xmlFreeInputStream(inputPop(ctxt)); |
| 13820 | |
| 13821 | return(ret); |
| 13822 | } |
| 13823 | |
| 13824 | /** |
| 13825 | * xmlReadDoc: |
no test coverage detected