|
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
[Back to original message]
|