
April 28th, 2008, 08:46 AM
|
|
Contributing User
|
|
Join Date: Apr 2007
Location: Stoke On Trent, England
Posts: 167
Time spent in forums: 15 h 33 m 21 sec
Reputation Power: 2
|
|
|
php5 - Xml noob
Hi using the example on http://uk.php.net/manual/en/simplexml.examples.php I am trying to understand the structure Here is my code and the error message
Code:
<?php
$xmlstr = <<<XML
<?xml version='1.0' standalone='yes'?>
<range>
<style>
<title>number 1</title>
<thumb>1.jpg</thumb>
<full>1f.jpg</full>
<desc type="embrace">blah blah</desc>
</style>
</range>
XML;
?>
PHP Code:
if ($_POST){
include 'example.php';
$childname=$_POST['childname'];
$childvalue=$_POST['childvalue'];
$xml = new SimpleXMLElement($xmlstr);
$title = $xml->range->style->addChild('title');
$title->addChild($childname, $childvalue);
$title->addChild($childname, $childvalue);
echo $xml->asXML();
}
Example #9 Adding elements and attributes
Fatal error: Call to a member function addChild() on a non-object in C:\Inetpub\wwwroot\buddin\index.php on line 8
Any help appreciated
__________________
There are 10 Kinds of people, those who know binary and those who don't
http://www.richinternet.co.uk
|