We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8478
    • 29 Posts
    Okay so I know that the RSS is an XML file, but I have been building more and more Flash apps with XML for data. Other then the news feeds, has anyone developed a widget to spit out XML files. Sorry if this is so short and lacking information... but I am pulling a long day and my eye lids are fighting with my pupils.

    The reason I ask is I am building a small web app to display images, and would like a way to use modX to build the XML files... need something user friendly for clients and non database developers such as my self.

    http://www.emeehan.com/downloads/wallgallery.html

    Thanks to anyone who can help or make sense of my sleepy babble.

    Ed
      -Ed
      • 4195
      • 398 Posts
      Take a look at this third party library -> MiniXML
        Armand Pondman
        MODx Coding Team
        :: Jot :: PHx
        • 22303 MODX Staff
        • 10,725 Posts
        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....
          • 8478
          • 29 Posts
          Cool, thanks for the quick response... I will look into it. That post was an impulse.... I had been working for 14 hours and just needed to pick someones brain.

          modx .... you guys rock

          Ed
            -Ed