Reputation: 95
This is not working but I can't figure out why...
Here is my xml
<customer>
<name>Cadence</name>
<city>Lake Katrine</city>
<state>NY</state>
<zip>12449</zip>
<email>[email protected]<email/>
</customer>
Here is my php
<?php
$xml=simplexml_load_file("customer.xml") or die("Error: Cannot create object");
echo $xml->name . "<br>";
echo $xml->city . "<br>";
echo $xml->zip;
?>
It won't echo, can someone tell me what I'm doing wrong?
Upvotes: 0
Views: 41
Reputation: 2553
Check this working code:
<?php
$xml=simplexml_load_file('http://www.w3schools.com/xml/note.xml') or die("Error: Cannot create object");
echo $xml->to . "<br>";
echo $xml->from . "<br>";
echo $xml->heading;
?>
Upvotes: 0
Reputation: 528
Check out closing tag of this line:
<email>[email protected]<email/>
Its should be like this:
<email>[email protected]</email>
Upvotes: 2