<DOCTYPE...> <html> ...blah blah blah... <div id="page">[*content*]</div> ...blah blah blah... </html>
I think that if your regular pages have templates something like:
<DOCTYPE...> <html> ...blah blah blah... <div id="page">[*content*]</div> ...blah blah blah... </html>
then that means that the content of that page is what you need to extract for your XML documents.
So you could create corresponding XML documents that reuse the content from those pages with Ditto or a simple snippet that grabs that content and reformats it in an XML template with an XML content-type. Then you should just be able to use the MODx-generated URLs for those XML pages within your AJAX script.
That way you don’t need to access the MODx database from outside it. MODx makes the XML documents and you put them together. Your AJAX page shouldn’t care where the XML came from as long as it’s got the right data in it.
There are surely other ways to do this as well...

<?php
/*
* Snippet Name: Get A Doc
* Short Desc: returns content from another page on the site as xml
* Author: Wiliam Harris
* Version: 0.1
* Last Edited: 30-Jan-2007
* Function: returns content from another page on the site as xml
*
* ok people I hope its readily apparent that I don't know what im doing but im workiing on it :)
* all help and suggestions appercieated (including speelling)
*
*/
$wpage = $_POST['docid'] ;
// set your default doc, there is probably a modx thing for this if anyone knows feel free to suggest
$wpage = isset($wpage)? $wpage : 5;
$doc = $modx->getDocument($wpage);
$wantedContent = $doc['content'];
$output = '<?xml version="1.0" encoding="'.$modx->config['etomite_charset'].'" ?>'."\n".
$wantedContent ;
return $output;
?>

Quote from: sirlancelot at Feb 12, 2007, 11:49 AM
Could you provide a live example of your solution? I’m not sure I understand what you’re doing. AJAX uses javascript and is not Search Engine Optimized since Search engines don’t parse links that use JS. It seems to me your solution hinders SEO.
sure here it is working
http://www.hustlemanent.com/
the point of the snippet works like this:
i have like 7 seven pages that all use the same template
the only difference is the content of one div with the id of "page"
this way all of the code that will ever be in any of the pages exists statically (not simplely as xml for an ajax request)
the content (xml) that is placed in the "page" div is in a modx document
now originally I wanted a function that could take a whole html page and crawl it with the dom to get the xml in the id page
this was because I was very new to both php and modx at the time and didn’t know that
a) php4 has *cough*piss*cough* poor xml support and
b) modx has a much simpler, faster, and easier solution
so what my snippet does instead is return the content of a modx document by its modx id formated as xml
i use a request variable "doc" to chose which ever document I want
if a visual would help your understanding better check out my xml generator here:
http://www.hustlemanent.com/xml
then try http://www.hustlemanent.com/xml?doc=18
you can also change it to 5,7,8, 9 and a few others
as you can see it works with gets but the actual script uses posts
give it a shot
and because the documents are all centered around the same template using the content of the "page" id/corresponding modx document from one in another doesn’t cause any problems
I also don’t use any inline javascript or javascript in the links. so if javascript is off the page works as if it was never there
, is will that still screw with my neophyte attempt at helping my site’s SEO?