* xmlReaderForMemory: * @buffer: a pointer to a char array * @size: the size of the array * @URL: the base URL to use for the document * @encoding: the document encoding, or NULL * @options: a combination of xmlParserOption * * Create an xmltextReader for an XML in-memory document. * The parsing flags @options are a combination of xmlParserOption. * * Returns the new reader or NULL
| 5188 | * Returns the new reader or NULL in case of error. |
| 5189 | */ |
| 5190 | xmlTextReaderPtr |
| 5191 | xmlReaderForMemory(const char *buffer, int size, const char *URL, |
| 5192 | const char *encoding, int options) |
| 5193 | { |
| 5194 | xmlTextReaderPtr reader; |
| 5195 | xmlParserInputBufferPtr buf; |
| 5196 | |
| 5197 | buf = xmlParserInputBufferCreateMem(buffer, size, XML_CHAR_ENCODING_NONE); |
| 5198 | if (buf == NULL) { |
| 5199 | return (NULL); |
| 5200 | } |
| 5201 | reader = xmlNewTextReader(buf, URL); |
| 5202 | if (reader == NULL) { |
| 5203 | xmlFreeParserInputBuffer(buf); |
| 5204 | return (NULL); |
| 5205 | } |
| 5206 | reader->allocs |= XML_TEXTREADER_INPUT; |
| 5207 | if (xmlTextReaderSetup(reader, NULL, URL, encoding, options) < 0) { |
| 5208 | xmlFreeTextReader(reader); |
| 5209 | return (NULL); |
| 5210 | } |
| 5211 | return (reader); |
| 5212 | } |
| 5213 | |
| 5214 | /** |
| 5215 | * xmlReaderForFd: |