|
Posted by Grizzly on 09/27/32 11:36
I can't remember where I found this on the internet, but it works (at
least in PHP 4)
File: input.xml
-----
<?xml version="1.0" encoding="ISO-8859-1"?>
<channel>
<item type="lie">
<title>Microsoft gives up on Windows</title>
<url>http://www.nothere.com/foo/bar</url>
</item>
<item type="lie">
<title>George Bush finds Iraq on map</title>
<url>http://www.somesite.com/news/4544.html</url>
</item>
<item type="lie">
<title>Man sells fridge to Eskimo</title>
<url>http://www.eskimostuff.com/blah/wombat.php</url>
</item>
</channel>
-------
file: style.xsl:
-----
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://my.netscape.com/rdf/simple/0.9/"
>
<xsl:output
method="html"
indent="no"
encoding="utf-8"
/>
<xsl:template match="/">
<xsl:for-each select="/channel/item">
INSERT INTO News (Title, Link) VALUES ('<xsl:value-of
select="title"/>', '<xsl:value-of select="url"/>')<BR/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
------
and now the php file to merge the two:
------
<?php
$xsltproc = xslt_create();
$xslt_result = xslt_process($xsltproc, 'input.xml', 'style.xsl');
xslt_free($xsltproc);
echo $xslt_result;
?>
------
Navigation:
[Reply to this message]
|