Using WPDB to output raw XML fails because of wp-blog-header.php

I’m coding a plugin. One particular file of this plugin is supposed to pull data from the plugin’s custom DB table, and output it with minimal processing as raw XML.

The problem is, to get the WPDB class to work when the file was opened directly, I had to add a require to wp-blog-header.php. This worked great BUT it turns out that including the file outputs the tags < html>, < head>, and < body>, which kinda screws up certain parts of the XML.

Is there any way I can
[A] Suppress the tag-spitting behavior of wp-blog-header.php?
[B] Get WPDB working in some other way?

Or should I just not use WPDB for DB access in this file in the plugin?

EDIT: False alarm. Firefox was adding the tags at the user’s end, not WordPress. Sorry for raising a big stink.

Solutions Collecting From Web of "Using WPDB to output raw XML fails because of wp-blog-header.php"

Include wp-load.php, not wp-blog-header.php. Better yet, hook onto the execution of a standard WordPress request and die early.

isset( $_GET['my_conditional_check'] ) && add_action( 'plugins_loaded', 'my_xml_output' );
function my_xml_output()
    // do my stuff

This’ll run WordPress, then my_xml_output(), then die before the request is actually parsed & the template is loaded/rendered: