| 
 Posted by James on 09/17/05 22:55 
Janwillem Borleffs wrote: 
  
> 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. 
  
 Perect, this is just what I was looking for. Thank you! 
 
>  
> $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(); 
>  
 
I was actually really trying to do something very similar to what you've got 
above. My issue was that when I set 
 
$body->item(0)->nodeValue .= '<b>blah</b>'; 
 
The tags would get a treatment with htmlentities(). I tried turning that 
behavior off: 
 
$dom->substituteEntities = false; 
 
But that didn't really do what I wanted. The CDATA markers do exactly what I 
need.  
 
> Posting is fine and even better then from some 'experienced' posters. 
 
Flattered :) 
 
Thanks again, 
James
 
  
Navigation:
[Reply to this message] 
 |