downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

DOMDocumentFragment::appendXML> <DOMDocument::xinclude
Last updated: Fri, 14 Aug 2009

view this page in

La classe DOMDocumentFragment

Synopsis de la classe

DOMDocumentFragment
DOMDocumentFragment étend DOMNode {
/* Propriétés */
/* Méthodes */
bool appendXML ( string $data )
/* Méthodes héritées */
DOMNode DOMNode::appendChild ( DOMNode $newnode )
DOMNode DOMNode::cloneNode ([ bool $deep ] )
public int DOMNode::getLineNo ( void )
bool DOMNode::hasAttributes ( void )
bool DOMNode::hasChildNodes ( void )
DOMNode DOMNode::insertBefore ( DOMNode $newnode [, DOMNode $refnode ] )
bool DOMNode::isDefaultNamespace ( string $namespaceURI )
bool DOMNode::isSupported ( string $feature , string $version )
string DOMNode::lookupNamespaceURI ( string $prefix )
string DOMNode::lookupPrefix ( string $namespaceURI )
void DOMNode::normalize ( void )
DOMNode DOMNode::removeChild ( DOMNode $oldnode )
DOMNode DOMNode::replaceChild ( DOMNode $newnode , DOMNode $oldnode )
}

Sommaire



add a note add a note User Contributed Notes
DOMDocumentFragment
mary dot kalinosky at thieme dot com
12-Aug-2009 10:43
I found DOMDocument very useful for extracting raw XML from a field in a MySQL database.

The following always gave me character entities for the XML tag brackets (&lt; &gt;) in the output (whether I used the utf8_encode function or htmlspecialchars function or neither of them on $row['text']):

<?php
$next_elem
= $doc->createElement( $row['node_type'], utf8_encode($row['text']) );
$section_elem->appendChild($next_elem);
?>

I changed the code to use a DOMDocumentFragment and now the XML I stored in my database comes out as XML in my output with proper tag brackets instead of html character entities:

<?php
$next_elem
= $doc->createDocumentFragment();
$next_elem->appendXML($row['text']);
$section_elem->appendChild($next_elem);
?>

DOMDocumentFragment::appendXML> <DOMDocument::xinclude
Last updated: Fri, 14 Aug 2009
 
 
show source | credits | sitemap | contact | advertising | mirror sites