Cannot parse xml content in php
Posted: Thu Mar 20, 2008 2:30 pm
Essentially I have some basic code out of the PHP Cookbook that should parse a xml document and print the firstname in this case. However clearly I have made a mistake. I originally tried using this technique on a much more complex xml and founcd that didn't work so I went t simplify it. K just get no output
Code: Select all
<?php
$ab='<?xml version="1.0">';
$ab.='<address-book>';
$ab.='<person id="1"';
$ab.='<firstname>David</firstname>';
$ab.='<lastname>Sklar</lastname>';
$ab.='</person>';
$ab.='</address-book>';
//echo $ab;
print $ab->person['firstname'] ."\n";
?>