Reputation: 16242
I have a php function that converts an object hierarchy to xml. asXML is not working as expected. Can anybody tell me why this:
$oReportXML = new SimpleXMLElement("<report></report>");
$oReportXML->addChild('details');
$oReportXML->addChild('configuration');
$oReportXML->addChild('datasources');
$oReportXML->addChild('styles');
$oReportXML->addChild('classes');
$oReportXML->addChild('tables');
$oReportXML->details->addChild('author',$this->iAuthor);
$oReportXML->details->addChild('date_created',$this->iDateCreated);
$oReportXML->details->addChild('date_modified',$this->iLastModifiedDate);
$oReportXML->details->addChild('modified_by',$this->iLastModifiedBy);
$oReportXML->details->addChild('id',$this->iReportID);
print_r($this);
print "<p>".$oReportXML->asXML()."</p>";
would output this:
Report Object ( [iAuthor] => 1 [iDateCreated] => 11 [iLastModifiedDate] => 1330435328 [iLastModifiedBy] => 1378 [iReportID] => 0 [sSubject] => sSubject [iCategory] => iCategory [sKeywords] => sKeywords [sDescription] => sDescription [sTitle] => IGNORE_ME [aTables] => Array ( ) [aClasses] => Array ( ) [aDataSources] => Array ( ) [aStyles] => Array ( ) [oParent:private] => )
111133043532813780
Upvotes: 1
Views: 2035
Reputation: 16045
print "<p>".htmlentities ($oReportXML->asXML())."</p>";
I think if you look into the source the xml is in there, but since you're looking it via browser which happens to dismiss all the tags, you're seeing only text nodes.
Upvotes: 3
Reputation: 26719
if you are looking the output in the browser, you will see only the values, as browsers do not visualize tags. Look at source code, or add header('Content-type:text/xml'); to tell the browser it should display XML
Upvotes: 0