-1

Possible Duplicate:
A simple program to CRUD node and node values of xml file

I have a .XML file, that showing the 20 newest jobs, Can anyone show how to displaying the data from the .xml file into a .php file (without javascript) where I can style the output?

<?xml version="1.0" encoding="utf-8"?>
<jobfeed>

<job>
<logo>http://google.com/logo.png</logo>
<Firmname>Google</Firmname>
<description> Pellentesque habitant morbi tristique senectus et netus.</description>
<title>CEO</title>
<location>London</location>
<date>1. December</date>
<link>http://www.google.com/jobs</link>
</job>

<job>
<logo>http://google.com/logo.png</logo>
<Firmname>Google</Firmname>
<description> Pellentesque habitant morbi tristique senectus et netus.</description>
<title>CEO</title>
<location>London</location>
<date>1. December</date>
<link>http://www.google.com/jobs</link>
</job>
</jobfeed>
Community
  • 1
  • 1
Jeppe
  • 11
  • 3

1 Answers1

0

You can use simplexml to parse the XML and output the HTML markup that you want.

<?php
$xml = <<<XML
<?xml version="1.0" encoding="utf-8"?>
<jobfeed>

<job>
<logo>http://google.com/logo.png</logo>
<Firmname>Google</Firmname>
<description> Pellentesque habitant morbi tristique senectus et netus.</description>
<title>CEO</title>
<location>London</location>
<date>1. December</date>
<link>http://www.google.com/jobs</link>
</job>

<job>
<logo>http://google.com/logo.png</logo>
<Firmname>Google</Firmname>
<description> Pellentesque habitant morbi tristique senectus et netus.</description>
<title>CEO</title>
<location>London</location>
<date>1. December</date>
<link>http://www.google.com/jobs</link>
</job>
</jobfeed>
XML;
$xml = simplexml_load_string($xml);
foreach($xml as $job) {
?>  
<div>
   <div class="tb"><img scr="<?php echo $job->logo ?>"/>
   etc ...
</div>
<?php } ?>
RageZ
  • 26,800
  • 12
  • 67
  • 76