PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old April 28th, 2008, 08:46 AM
Foddski Foddski is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Stoke On Trent, England
Posts: 167 Foddski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #2  
Old May 7th, 2008, 07:28 PM
icandothat's Avatar
icandothat icandothat is offline
Moderator
Click here for more information.
 
Join Date: Apr 2007
Location: San Diego, CA
Posts: 1,551 icandothat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 2 h 55 m 16 sec
Reputation Power: 3
well either $xml or $title is not an object.

just do an
echo is_object($xml)."<BR>";
echo is_object($title)."<BR>";
to test which one is not an object.
__________________
There is no spoon.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > php5 - Xml noob


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway