XML to PHP

admin

Administrator
Staff member
Hi All

I have simple XML code which I have used XSLT to output, both files are pasted below and the result can be seen at <!-- m --><a class="postlink" href="http://itsuite.it.brighton.ac.uk/pjgh1/birds.xml">http://itsuite.it.brighton.ac.uk/pjgh1/birds.xml</a><!-- m -->.
This was for experimental purposes, I now want to display the XML data on a PHP page but am incertain as to how, I have trawled the web and can't get my head round some of the solutions found as i loathe trying to unravel someone elses complicated, poorly explained code and tend to start daydreaming after about 3 seconds. Can anyone suggest a straightforward solution?

Many Thanks

Solaar

BIRDS.XML
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited with XML Spy v2006 (<!-- m --><a class="postlink" href="http://www.altova.com">http://www.altova.com</a><!-- m -->) -->
<?xml-stylesheet type="text/xsl" href=http://www.webdeveloper.com/forum/archive/index.php/"birds.xsl" ?>
<British_Birds>
<species>
<name>Golden oriole</name>
<latin>Oriolus oriolus</latin>
<status>Summer</status>
<breeding>9-42</breeding>
<passage>85</passage>
<Image ID="123" URI="golden_oriole.jpg"/>
<url address="www.rspb.org.uk/birds/guide/g/goldenoriole/index.asp" />
</species>
<species>
<name>Sparrowhawk</name>
<latin>Accipiter nisus</latin>
<status>Resident</status>
<breeding>34,500</breeding>
<passage>0</passage>
<Image ID="123" URI="sparrowhawk.jpg"/>
<url address="www.rspb.org.uk/birds/guide/s/sparrowhawk/index.asp" />
</species>
<species>
<name>Siskin</name>
<latin>Carduelis spinus</latin>
<status>Resident/Winter</status>
<breeding>310,000</breeding>
<passage>0</passage>
<Image ID="123" URI="siskin.jpg"/>
<url address="www.rspb.org.uk/birds/guide/s/siskin/index.asp" />
</species>
<species>
<name>Hoopoe</name>
<latin>Upupa epops</latin>
<status>Passage</status>
<breeding>Occasional</breeding>
<passage>100</passage>
<Image ID="123" URI="hoopoe.jpg"/>
<url address="www.rspb.org.uk/birds/guide/h/hoopoe/index.asp" />
</species>
</British_Birds>
BIRDS.XSL
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited with XML Spy v2006 (<!-- m --><a class="postlink" href="http://www.altova.com">http://www.altova.com</a><!-- m -->) -->

<html xsl:version="1.0" xmlns FPRIVATE "TYPE=PICT;ALT=" sl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">

<body style="font-family:Arial,helvetica,sans-serif;font-size:12pt; background-color:#EEEEEE">

<h1>British Birds</h1>

<table border="1" width="75%" bordercolor="#111111">
<tr><th></th><th>Species</th><th>Latin</th><th>Status</th>
<th>Breeding</th><th>Passage</th><th>more info</th></tr>
<xsl:for-each select="British_Birds/species">
<tr>
<td width="5%">
<img src="{Image/@URI}" height = "65" width = "50"/>
</td>
<td width="25%">
<span style="font-style:enbolden">
<xsl:value-of select="name" />
</span>
</td>
<td width="10%">

<span style="font-style:italic">

<xsl:value-of select="latin" />

</span>
</td>
<td width="25%">
<xsl:value-of select="status" />
</td>

<td width="10%">
<xsl:value-of select="breeding " />
breeding pairs
</td>
<td width="10%">
<xsl:value-of select="passage" />
birds
</td>
<td width="10%">
<a href="{url/@address}">more...</a>

</td>
</tr>

</xsl:for-each>
</table>
</body>
</html>
 
Back
Top