You are here: Re: [PHP] SimpleXML add a node « PHP « IT news, forums, messages
Re: [PHP] SimpleXML add a node

Posted by Richard Lynch on 10/04/42 11:10

>> php.net/dom
>
> ??
>
> Like this?
>
> ---
>
> try {
>
> $dom = new DOMDocument();
>
> $config =
> $dom->appendChild($dom->importNode(dom_import_simplexml($this->configXML),true));
>
> $config->appendChild( $dom->createElement(($mode? 'softactive':'active'))
> );
>
> $this->configXML = simplexml_import_dom($config);
>
> } catch(Exception $e) {}

I dunno about that whole try/catch thing, but if you're not going to USE
it to catch the errors, then you might as well be old school and check the
return values of all these functions.

> It ist strange... It runs one time, the second time I receive the
> following
> error.

Since it "works" once and not the second time, I'd be looking to see if
the XML produced on the first go-around is actually VALID, since, if it's
not, that would cause this problem, I think.

> Warning: DOMDocument::importNode() [function.importNode]: Cannot import:
> Node Type Not Supported in ...

So what's the Node Type (whatever that is) of the Node you are importing?

> Warning: appendChild() expects parameter 1 to be DOMNode, boolean given in
> ...
>
> Fatal error: Call to a member function appendChild() on a non-object in
> ...

--
Like Music?
http://l-i-e.com/artists.htm

 

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

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