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

Posted by Jerry Stuckle on 04/03/07 20:01

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

Where are you loading your XML file, and what does it look like?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

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

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