You are here: Re: [PHP] Re: Using DOM object, how? « PHP « IT news, forums, messages
Re: [PHP] Re: Using DOM object, how?

Posted by Ken Tozier on 09/20/05 01:13

Thanks Jasper

Works perfectly on my Mac now as well.

Ken

On Sep 19, 2005, at 4:58 PM, Jasper Bryant-Greene wrote:

> <?php
> $x = new MyDom();
> $x->createScriptElement('howdy.js');
> print($x->saveXML());
>
> class MyDom {
> private $dom;
>
> /* __construct() = PHP5 constructor */
> function __construct() {
> $this->dom = new DOMDocument('1.0', 'iso-8859-1');
> /* No need to return $this from a constructor */
> }
>
> function createScriptElement($scriptPath) {
> $script = $this->dom->createElement('script', '');
> $script->setAttribute('type', 'text/javascript');
> $script->setAttribute('src', $scriptPath);
> $this->dom->appendChild($script);
> /*
> Doesn't make sense for a createScriptElement()
> method to also print out the XML, so I made a
> separate method and called that from the
> mainline code.
> */
> }
>
> function saveXML() {
> return $this->dom->saveXML();
> }
> }
> ?>

 

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

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