snowboardr
Programmer
I am unable to get the following script to display anything and i have modified it multiple times to try and get it to work before posting this:
index.php
myfile.xml
[/code]
<?xml version="1.0"?>
<item>
<description>Hello!</description>
</item>
[/code]
however this works fine:
example.php
Jason
[red]Army[/red] : [white]Combat Engineer[/white] : [blue]21B[/blue]
index.php
Code:
<?php
if (file_exists('myfile.xml')) {
$xml = simplexml_load_file('myfile.xml');
//print_r($xml);
echo $xml->item->description;
} else {
exit('Failed to open test.xml.');
}
?>
myfile.xml
[/code]
<?xml version="1.0"?>
<item>
<description>Hello!</description>
</item>
[/code]
however this works fine:
Code:
<?php
include 'example.php';
$xml = new SimpleXMLElement($xmlstr);
echo $xml->movie[0]->plot; // "So this language. It's like..."
?>
example.php
Code:
<?php
$xmlstr = <<<XML
<?xml version='1.0' standalone='yes'?>
<movies>
<movie>
<title>PHP: Behind the Parser</title>
<characters>
<character>
<name>Ms. Coder</name>
<actor>Onlivia Actora</actor>
</character>
<character>
<name>Mr. Coder</name>
<actor>El ActÓr</actor>
</character>
</characters>
<plot>
So, this language. It's like, a programming language. Or is it a
scripting language? All is revealed in this thrilling horror spoof
of a documentary.
</plot>
<great-lines>
<line>PHP solves all my web problems</line>
</great-lines>
<rating type="thumbs">7</rating>
<rating type="stars">5</rating>
</movie>
</movies>
XML;
?>
Jason
[red]Army[/red] : [white]Combat Engineer[/white] : [blue]21B[/blue]