Reformatting/Sanitizing XML output into a simpler node tree - XSL/XSLT transformation with PHP

    I am outputing some Views from a site running Drupal-5 (yet to upgrade) and I need to channel this information for consumption by a Flash animation that will scroll through the information that will be managed in the said Drupal site. Drupal-5 does nto provide a very flexible approach to generating XML/RSS with vustom fields from a VIEW. Ofcourse it can generate XML output, but the node structure leaves quite a bit to be desired.

    So I am employing an XSLT and a few lines of PHP to fish through the convoluted XML file to rebuild a nice cleaner and more precise XML node tree.

    The PHP

    <?php
    $xml = new DomDocument;
    $xml->load('http://myxmlsource.idonny.net.org/viewoutputfile?format=idxml');

    $xsl = new DomDocument;
    $xsl->load('http://idonny.net/sites/mypath/themes/cbixml/case_rss.xslt');

    $proc = new xsltprocessor;
    $proc->importStyleSheet($xsl);
    $result = $proc->transformToXML($xml);
    print $result; // print output of the mash
    ?>

    Here is the XSLT file that is being applied to the colvoluted XML

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output
    method="xml"
    encoding="ISO-8859-1"
    omit-xml-declaration="no"
    standalone="no"
    cdata-section-elements="description"
    indent="yes"
    media-type="text/xml" />
    <xsl:template match="/drupal_page/div/div/div/ul">
    <cbixml>
    <xsl:for-each select="li">
        <cbinode>
            <title><xsl:value-of select="node/title"/></title>
             <industry_sector><xsl:value-of select="node/industry_sector/ul/li/a"/></industry_sector>
             <link>http://idonny.com/node/<xsl:value-of select="node/id"/></link>
             <id><xsl:value-of select="node/id"/></id>
             <image_path><xsl:value-of select="node/image/img/@src"/></image_path>
             <description><xsl:value-of select="node/description"/></description>
        </cbinode>
    </xsl:for-each><!-- /item -->
    </cbixml>
    </xsl:template>
    </xsl:stylesheet>

    Naturally, you can have the XSLT file pull and place anything you want fromt eh source XML file to result in a new strcuture/format

    Enjoy!