You are here: Re: xml to sql? « All PHP « IT news, forums, messages
Re: xml to sql?

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация