WordPress ships with an XML-RPC interface that’s enabled by default. It gives you the ability to both retrieve and edit/create content on the site via XML.
There’s quite a bit of detail about the API available on the Codex.
Updated
There aren’t (to my knowledge) any existing systems in place that do XML over GET for WordPress. Webpages tend to be some form of (X)HTML already and, if following the XHTML spec closely, your theme alone might produce something parse-able.
However, that’s not the only option in place.
If you take a look at some of the newer AMP work being done with WordPress, you’ll see how developers are leveraging custom URL rewrite endpoints to serve different content for the same resource. For example:
- http://yoursite.com/2016/09/cool-post-bro – Delivers standard HTML
- http://yoursite.com/2016/09/cool-post-bro/amp – Delivers AMP markup
You could use the same pattern to code an /xml
rewrite endpoint that presents your post in whatever arbitrary markup as you need.
To get you started …
Enable an endpoint
function xml_init() {
add_rewrite_endpoint( 'xml', EP_PERMALINK );
}
add_action( 'init', 'xml_init' );
Intercept requests so you can prepare XML
function xml_maybe_change_markup() {
if ( ! is_singular() || is_feed() ) return;
// Only intercept the right requests
if ( false === get_query_var( 'xml', false ) ) return;
add_action( 'template_redirect', 'xml_render' );
}
add_action( 'wp', 'xml_maybe_change_markup' );
Actually render XML
function xml_render() {
$post_id = get_queried_object_id();
// Get the post, build your XML document, print it to the page
exit;
}
As I don’t know what exact output you need, I leave building the XML document as an exercise for you 🙂