I currently have this XML and simply want it displayed in the browser. I have tried using Simple XMl and it just does not seem to work - please help me think of something!!!
XML Code
<?xml version=“1.0” encoding=“UTF-8”?>
<Total_articles>
<article titles=“Portfolio exhibition by new members of Association of Photographers” date=“February 2008” description=“I am participating in the Association of Photographers (AoP) annual “Portfolio” exhibition at the AoP Gallery. The exhibition is a platform for newcomers to the AoP to display their latest campaigns, assignments, commissions and personal projects. I will be exhibiting three pieces, including two new panoramic images from personal projects.” />
<article titles=“Untitled 2007 group show of local commercial photographers” date=“December 2007” description=“Ten commercial photographers principally based in and around West London (myself included) are putting on a pre-Christmas show. Using the elegant function room of the George and Devonshire in Chiswick as a backdrop, this very eclectic mix of professionals – who work in fields as varied as architecture, portraiture, performance, still-life and fine-art – are displaying some of their best recent work.” />
<article titles=“Granada trip” date=“November 2007” description=“Instead of a summer holiday this year, we went to Granada for an autumn break. The region is full of interesting things: the Sierra Nevada mountains and valleys, the alternative lifestyles on its slopes (including gypsy caves and new age traveller tepees), hills full of modern windmills and fields full of solar panels, old Wild West movie sets, and of course the amazing Alhambra.” />
</Total_articles>
I have tried using the following bu does not work:
<?php
// define the url that will return the xml
$xml_url = ‘books.xml’;
// use this function to store the xml tree in a variable
$sxml = simplexml_load_file($xml_url);
// print the content of $sxml
print_($sxml);
// if you want to get particular values of the xml tree, use a loop
foreach($var as $key=>$value)
{
echo $key.‘=>’.$value;
echo ‘<br />’;
}
?>
This gives me the error:
Fatal error: Call to undefined function print_() in /homepages/25/d220261013/htdocs/xml/blogger.php on line 10
SimpleXMLElement Object ( [article] => SimpleXMLElement Object ( [@attributes] => Array ( [titles] => One day [date] => February 2008 [description] => Please work ) ) ) Warning: Invalid argument supplied for foreach() in /homepages/25/d220261013/htdocs/xml/blogger.php on line **13
**It picks up the article but also gives some other stuff about simple xml as well.
I only want the title, date and description- how is that possible. BTW, thanks for the help.
SimpleXMLElement Object ( [article] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [titles] => One day [date] => February 2008 [description] => This is the first article ) ) [1] => SimpleXMLElement Object ( [@attributes] => Array ( [titles] => Second day [date] => March 2008 [description] => This is the second article ) ) ) ) article=>
article=>
thank you kitsunegari for all your help. you are a life saver. one more thing. if i put an image link in my articles.xml, how do i use simple xml to output it on screen to appear as an image?
I currently added a ‘arts’ link at the end:
<?xml version=“1.0” encoding=“utf-8”?>
<Total_articles>
<article titles=“One day” dates=“February 2008” descriptions=“This is the first article” [COLOR=“Blue”]arts=“blog_art/1.jpg”[/COLOR] />
<article titles=“Second day” dates=“March 2008” descriptions=“This is the second article” [COLOR=“blue”]arts=“blog_art/2.jpg”[/COLOR] />
</Total_articles>
echo $value[‘arts’];
> this only shows me the link, but i want it to display as an image on screen.