You are here: Re: php and xml DomDocument « PHP Programming Language « IT news, forums, messages
Re: php and xml DomDocument

Posted by Andy Hassall on 04/03/07 22:51

On 3 Apr 2007 08:39:53 -0700, ibidrin@googlemail.com wrote:

>Hi Ng,
>a error occurs in my class Articles in which i try to add an element
>to an existing xml-file.
> $var_dump($channels) >>>> object(DOMNOdeList)+6 (0) {}
>$var_dump($channels->length) >>>> int(0)
>$var_dump($channels->item(0)) >>>> NULL
>
>The tag article exists in the xml-file but it were not found by method
>getElementsByTagName.
>Following error were occur:
>
>Fatal error: Call to a member function appendChild() on a non-object
>in ...
>
>
>Any suggestions?
>
>
>class Article extends DomDocument
>{
> public function __contruct()

What's your actual code, or is this typo in your real code as well?

> {
> parent::__contruct('1.0','utf-8');
> }
> public function addArticle($title, $text)
> {
> $newItem = $this->createElement('item');
> $newTitle = $this->createElement('title');
> $newTitle->appendChild($this->createTextNode($title));
> $newItem->appendChild($newTitle);
> $newText = $this->createCDATASection($text);
> $newItem->appendChilde($newText);
> $channels = $this->getElementsByTagName('articles');
> //hier bekomme ich den Fehler, obwohl es den Tag "arcticles" gibt

"arcticles" or "articles" ?

> $channels->item(0)->appendChild($newItem);
> //andere Ideen wie ich einen neuen Text in einer bestehender xml-
>Datei
>anhängen kann?
> }
>}

--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация