* xmlReadFile: * @filename: a file or URL * @encoding: the document encoding (optional) * @options: a combination of xmlParserOption * * Convenience function to parse an XML file from the filesystem, * the network or a global user-define resource loader. * * See xmlCtxtReadFile for details. * * Returns the resulting document tree */
| 13872 | * Returns the resulting document tree |
| 13873 | */ |
| 13874 | xmlDocPtr |
| 13875 | xmlReadFile(const char *filename, const char *encoding, int options) |
| 13876 | { |
| 13877 | xmlParserCtxtPtr ctxt; |
| 13878 | xmlParserInputPtr input; |
| 13879 | xmlDocPtr doc; |
| 13880 | |
| 13881 | ctxt = xmlNewParserCtxt(); |
| 13882 | if (ctxt == NULL) |
| 13883 | return(NULL); |
| 13884 | |
| 13885 | xmlCtxtUseOptions(ctxt, options); |
| 13886 | |
| 13887 | /* |
| 13888 | * Backward compatibility for users of command line utilities like |
| 13889 | * xmlstarlet expecting "-" to mean stdin. This is dangerous and |
| 13890 | * should be removed at some point. |
| 13891 | */ |
| 13892 | if ((filename != NULL) && (filename[0] == '-') && (filename[1] == 0)) |
| 13893 | input = xmlNewInputFd(ctxt, filename, STDIN_FILENO, encoding, 0); |
| 13894 | else |
| 13895 | input = xmlNewInputURL(ctxt, filename, NULL, encoding, 0); |
| 13896 | |
| 13897 | doc = xmlCtxtParseDocument(ctxt, input); |
| 13898 | |
| 13899 | xmlFreeParserCtxt(ctxt); |
| 13900 | return(doc); |
| 13901 | } |
| 13902 | |
| 13903 | /** |
| 13904 | * xmlReadMemory: |