PHP Doku:: The DOMDocumentFragment class - class.domdocumentfragment.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzXML-ManipulationDocument Object ModelThe DOMDocumentFragment class

Ein Service von Reinhard Neidl - Webprogrammierung.

Document Object Model

<<DOMDocument::xinclude

DOMDocumentFragment::appendXML>>


UnterSeiten:

The DOMDocumentFragment class

Klassenbeschreibung

DOMDocumentFragment extends DOMNode {
/* Eigenschaften */
/* Methoden */
bool appendXML ( string $data )
/* Geerbte Methoden */
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 )
}

Inhaltsverzeichnis


Ein BenutzerBeitrag:
- Beiträge aktualisieren...
mary dot kalinosky at thieme dot com
13.08.2009 0: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);
?>



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)