domxml_open_mem

(PHP 4 >= 4.2.0)

domxml_open_mem — Creates a DOM object of an XML document

Описание

DomDocument domxml_open_mem ( string $str [, int $mode [, array &$error ]] )

The function parses the XML document in the given string.

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

str

The contents of the XML file.

mode

This optional parameter can be used to change the behavior of this function.

You can use one of the following constants for it: DOMXML_LOAD_PARSING (default), DOMXML_LOAD_VALIDATING or DOMXML_LOAD_RECOVERING. You can add to it also DOMXML_LOAD_DONT_KEEP_BLANKS, DOMXML_LOAD_SUBSTITUTE_ENTITIES and DOMXML_LOAD_COMPLETE_ATTRS by bitwise or.

error

If used, it will contain the error messages. error must be passed in by reference.

Возвращаемые значения

Returns a DomDocument instance of the given XML contents.

Список изменений

Версия Описание
4.3.0 The mode and error parameters were added.

Примеры

Пример #1 Opening an XML document in a string

<?php
include("example.inc");

if (!
$dom domxml_open_mem($xmlstr)) {
  echo 
"Error while parsing the document\n";
  exit;
}

$root $dom->document_element();
?>

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

[an error occurred while processing the directive]

Коментарии

You can also create a new DomDocument instance by calling its constructor:

<?php
  $doc 
= new DomDocument($xml);
?>

where $xml is any string of well-formed XML.
2003-10-16 13:10:39
http://php5.kiev.ua/manual/ru/function.domxml-open-mem.html
Careful, this function will not work with XML documents which are in UTF-16 or UTF-32 encoding and include a BOM at the beginning, so your code will need a special handling for these encodings.
2004-08-19 17:28:35
http://php5.kiev.ua/manual/ru/function.domxml-open-mem.html
Автор:
Regarding the 'magic_quotes_runtime = On' issue in XML parsing, I will suggest using the method below, for those who do not want to turn off the setting in the configuration file.

<?php

$original
-magic-quotes-runtime-value get_magic_quotes_runtime();

set_magic_quotes_runtime(0);

your-xml-parsing-codes();

set_magic_quotes_runtime($original-magic-quotes-runtime-value);

?>
2004-10-08 10:40:48
http://php5.kiev.ua/manual/ru/function.domxml-open-mem.html

    Поддержать сайт на родительском проекте КГБ