ne_xml_parse_response
Prev | neon API reference | Next

## Name

ne_xml_parse_response, ne_xml_dispatch_request, ne_xml_dispatchif_request — helper functions for parsing XML responses

## Synopsis

    #include <ne_xmlreq.h>

``int ne_xml_parse_response(`ne_request *req, ne_xml_parser *parser`)`;`
``int ne_xml_dispatch_request(`ne_request *req, ne_xml_parser *parser`)`;`
``int ne_xml_dispatchif_request(`ne_request *req, ne_xml_parser *parser, ne_accept_response acceptor, void *userdata`)`;`

## Description

The `ne_xml_parse_response` function reads an HTTP response body and processes it using the given XML parser. The function must be called `ne_begin_request` has returned successfully for the request, and then invokes `ne_read_response_block` until the entire response body has been read. On successful return, `ne_end_request` must be called to finalise response processing.

The `ne_xml_dispatch_request` and `ne_xml_dispatchif_request` functions is equivalent to calling ne_request_dispatch to dispatch an HTTP request and process the response, parsing the response body using the given XML parser under certain conditions:

- For `ne_xml_dispatch_request`, any `2xx` class response with an XML content-type.
- For `ne_xml_dispatchif_request`, if the `acceptor` callback returns non-zero, and the response uses an XML content-type.

In both cases, the rules in RFC 7303 are followed to identify XML content-types, that is `text/xml`, `application/xml`, or any other content-type ending in a `+xml` suffix. The `userdata` parameter is passed to the `acceptor` function.

For all three functions:

- the XML parser is invoked repeatedly until the end of the document is reached.
- if an error occurs during XML parsing, the session error string is set to describe the parse error, and the connection is terminated without continuing to process the response..

## Return value

All functions documented here return zero on success, or an NE_* error code on failure.

## History

`ne_xml_dispatchif_request` is available in neon 0.36.0 and later.

## See also

ne_xml_create, ne_request_dispatch

Prev | Up | Next
ne_xml_create | Home | Bibliography