Введение
The DOM extension allows you to operate on XML documents through the DOM API with PHP 5.
For PHP 4, use DOM XML.
Замечание: DOM extension uses UTF-8 encoding. Use utf8_encode() and utf8_decode() to work with texts in ISO-8859-1 encoding or Iconv for other encodings.
- Введение
- Установка и настройка
- Предопределенные константы
- Examples
- Класс DOMAttr
- Класс DOMCdataSection
- Класс DOMCharacterData
- Класс DOMComment
- Класс DOMDocument
- Класс DOMDocumentFragment
- Класс DOMDocumentType
- Класс DOMElement
- Класс DOMEntity
- Класс DOMEntityReference
- Класс DOMException
- Класс DOMImplementation
- Класс DOMNamedNodeMap
- Класс DOMNode
- Класс DOMNodeList
- Класс DOMNotation
- Класс DOMProcessingInstruction
- The DOMText class
- Класс DOMXPath
- DOM Функции
Коментарии
Be careful when using this for partial HTML. This will only take complete HTML documents with at least an HTML element and a BODY element. If you are working on partial HTML and you fill in the missing elements around it and don't specify in META elements the character encoding then it will be treated as ISO-8859-1 and will mangle UTF-8 strings. Example:
<?php
$body = getHtmlBody();
$doc = new DOMDocument();
$doc->loadHtml("<html><body>".$body."</body></html>");
// $doc will treat your HTML ISO-8859-1.
// this is correct but may not be what you want if your source is UTF-8
?>
<?php
$body = getHtmlBody();
$doc = new DOMDocument();
$doc->loadHtml("<html><head><meta charset=\"UTF-8\"><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"></head><body>".$body."</body></html>");
// $doc will treat your HTML correctly as UTF-8.
?>