DOMDocument->__construct()

(no version information, might be only in CVS)

DOMDocument->__construct() --  Creates a new DOMDocument object

Описание

class DOMDocument {

__construct ( [string version [, string encoding]] )

}

Creates a new DOMDocument object.

Список параметров

version

The version number of the document as part of the XML declaration.

encoding

The encoding of the document as part of the XML declaration.

Примеры

Пример 1. Creating a new DOMDocument

<?php

$dom
= new DOMDocument('1.0', 'iso-8859-1');

echo
$dom->saveXML(); /* <?xml version="1.0" encoding="iso-8859-1"?> */

?>

Смотрите также

DOMImplementation->createDocument()



DOMDocument->__construct()
b dot schoppmeier at bas-consult dot de
11-Jul-2006 01:53
Handling of document encoding seems to be inconsistent:

I created a document, loaded a HTML file, tweaked it a bit and pushed it to the browser as in

   $doc = new DOMDocument();
   $doc->loadHTML($file);
   /*
   manipulate the document
   /*
   $outString = $doc->saveXML();

Text from the HTML file was ruined if it contained umlauts.

Creating the document with

   $doc = new DOMDocument("1.0","ISO-8889-1");

solved this problem.

But, when I set attributes to DOMElements where the attribute value contained umlauts those values still
appeared ruined.

Explicitly converting the attribute value to utf-8 as in

   $element->setAttribute($name, utf8_encode($value));

solved that problem too.

<DOMComment->__construct()DOMDocument->createAttribute()>
 Last updated: Tue, 15 Nov 2005