Obviously, it totally depends on the source of the data, but here is an example of a GeoRSS feed XML snippet I wrote that uses children of a specified document to generate XML content that is returned into a MODx document. The MODx document is of type text/xml, includes the appropriate XML header, and the call to this snippet... just an example...
<?php
$xmlContent= '';
if (isset ($startId)) {
$rssItemContent= isset ($rssItemTpl)? $modx->getChunk($rssItemTpl): '';
if (empty ($rssItemContent)) {
$rssItemContent= " <item>
<title>[+georss.pagetitle+]</title>
<link><![CDATA[[+georss.link+]]]></link>
<description>[+georss.description+]</description>
<ymaps:Address>[+georss.tv.address+]</ymaps:Address>
<ymaps:CityState>[+georss.tv.city+], [+georss.tv.state+]</ymaps:CityState>
<ymaps:Zip>[+georss.tv.zip+]</ymaps:Zip>
<ymaps:Country>[+georss.tv.country+]</ymaps:Country>
</item>
";
}
if ($children= $modx->getActiveChildren($startId)) {
foreach ($children as $child) {
$itemContent= '';
if ($childTVs= $modx->getTemplateVarOutput("*", $child['id'])) {
foreach ($childTVs as $name => $object) {
$child["tv.{$name}"]= "{$object}";
}
}
$child['link']= $modx->makeUrl($child['id']);
$itemContent= $rssItemContent;
foreach($child as $key => $value) {
$itemContent= str_replace('[+georss.'.$key.'+]', $value, $itemContent);
}
$xmlContent.= $itemContent;
}
}
}
return $xmlContent;
?>
Here’s the document content...
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
xmlns:ymaps="http://api.maps.yahoo.com/Maps/V2/AnnotatedMaps.xsd">
<channel>
<title>[*pagetitle*]</title>
<link><![CDATA[[(site_url)]]]></link>
<description>[*description*]</description>
[[YahooGeoRSS? &startId=`2` &rssItemTpl=`YahooGeoRSSTemplate`]]
</channel>
</rss>
I also used a chunk as a template called YahooGeoRSSTemplate...
<item>
<title>[+georss.pagetitle+]</title>
<link><![CDATA[[+georss.link+]]]></link>
<description>[+georss.description+]
Units: [+georss.units+]
Amenities:[+georss.amenities+]
</description>
<ymaps:Address>[+georss.tv.address+]</ymaps:Address>
<ymaps:CityState>[+georss.tv.city+], [+georss.tv.state+]</ymaps:CityState>
<ymaps:Zip>[+georss.tv.zip+]</ymaps:Zip>
<ymaps:Country>[+georss.tv.country+]</ymaps:Country>
</item>
You can use this same technique to produce any format XML with MODx...hopefully it sparks some ideas on how to approach your problem....