|
|
DOMDocument->loadHTML() (no version information, might be only in CVS) DOMDocument->loadHTML() --
Load HTML from a string
Описаниеclass DOMDocument { bool loadHTML ( string source ) }
The function parses the HTML contained in the string source.
Unlike loading XML, HTML does not have to be well-formed to load. This
function may also be called statically to load and create a
DOMDocument object. The static invocation may be
used when no DOMDocument properties need to be
set prior to loading.
Возвращаемые значения
Возвращает TRUE в случае успешного завершения или FALSE в случае возникновения ошибки.
Примеры
Пример 1. Creating a Document |
<?php
$doc = new DOMDocument();
$doc->loadHTML("<html><body>Test<br></body></html>");
echo $doc->saveHTML();
?>
|
|
add a note
User Contributed Notes
DOMDocument->loadHTML()
xuanbn at yahoo dot com
04-Oct-2007 01:38
If you use loadHTML() to process utf HTML string (eg in Vietnamese), you may experience result in garbage text, while some files were OK. Even your HTML already have meta charset like
<meta http-equiv="content-type" content="text/html; charset=utf-8">
I have discovered that, to help loadHTML() process utf file correctly, the meta tag should come first, before any utf string appear. For example, this HTML file
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title> Vietnamese - Ti
|
|