Re: Re: Using DOM object, how?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Monday 19 September 2005 12:25 pm, Ken Tozier wrote:
> > I would be extremely careful with this.. because sadly PHP's XML
> > generator
> > uses the short form whenever possible.
> > <script /> will *NOT* work in most browsers such as FireFox.
> > <script></script> Will work.
>
> Thanks for the heads up. Looks like if you define the tag like
> $script        = $dom->createElement('script',''); <-- empty string
> It tacks on an end tag.
The way that I've been doing this thus far is using XSL. If you use the 
DOMDocument::loadXML() function and it has anything like that. it will 
convert it to short form.
I design the back XML using Dom calls then throw a xsl at it to spit out my 
page. very nice clean code that's separated from style.

>
> So far, just playing. But ultimately I'd like to generate the whole
> page using dom calls. It seems much cleaner for what I'm doing than
> creating a whole bunch of large functions that do nothing more than
> echo prestyled html.

Is this clean enough? :)
minimum for one of my pages that uses SQL:
<?php
	include("Document.php");

	// a DOM Object is auto generated along with an XPath object to go with it.
	// $Document->gDom() and $Document->gXPath() to gain access to them.
	$Document = new Document("rootNode");
	try {
		$Document->gDb()->connect(Database::SQLITE,"../database.db");
	} catch (DBConnectFailed $dbCF) {
		die("Failed to connect to the Database.");
	}
	$Document->setTitle("This is the title");
	// Use $Document->setStylesheet(""); to set a stylesheet, 
	// defaults to index.xsl.

	// Here is where you put the page specific code.
	// XML data nodes used in the XSL template.

	// This outputs the header(); and the DocType.
	$Document->outputHeader();
	echo $Document;	// This will load the XSL document, apply it, and return 
					// The page to be echo'd
?>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux