Reply to Re: appendData() DOM

Your name:

Reply:


Posted by Janwillem Borleffs on 09/18/05 01:36

James wrote:
> Hello everyone. I've been looking for examples on this:
>
> http://www.php.net/manual/en/functi...-appenddata.php
>
> but can't really find one. I've got a function that generates a
> return value in HTML, and need to append that to the body tag of my
> document. So I've captured the contents of the page with output
> buffering, and have loaded it into the PHP DOM. I've isolated the
> body element:
>

CDATA is data encapsuled between '<![CDATA[' and ']]>' markers. The
advantage of CDATA sections is that you can put anything in between,
including invalid xml and/or characters as these sections are ignored by the
parser.

But what you probably need is just to append a value to the body tag's node
value, which is done as follows:

$buffer = '<html><body>bla</body></html>';
$dom = new DomDocument;
$dom->LoadHTML($buffer);
$body = $dom->getElementsByTagName('body');
$body->item(0)->nodeValue .= ' bla';

// Prints: <html><body>bla bla</body></html>
print $dom->saveHTML();

> ps. This is my first post to a newsgroup... Sorry if I'm posting this
> improperly or something.

Posting is fine and even better then from some 'experienced' posters.


JW

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

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