Files
php-doc-ru/reference/simplexml/functions/simplexml-import-dom.xml
Sergey Panteleev 6d43fd64d7 Исправление форматирования
[skip-spellcheck]
[skip-lint]
2022-12-27 03:42:36 +03:00

120 lines
3.6 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 5916fd8f742127259912e6510904451849928020 Maintainer: aur Status: ready -->
<!-- Reviewed: no -->
<refentry xml:id="function.simplexml-import-dom" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>simplexml_import_dom</refname>
<refpurpose>
Получает объект класса <literal>SimpleXMLElement</literal> из узла DOM
</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type class="union"><type>SimpleXMLElement</type><type>null</type></type><methodname>simplexml_import_dom</methodname>
<methodparam><type class="union"><type>SimpleXMLElement</type><type>DOMNode</type></type><parameter>node</parameter></methodparam>
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>class_name</parameter><initializer>SimpleXMLElement::class</initializer></methodparam>
</methodsynopsis>
<para>
Эта функция берет узел документа <link linkend="book.dom">DOM</link> и превращает его
в узел SimpleXML. Затем этот новый объект может быть использован как первичный элемент
SimpleXML.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>node</parameter></term>
<listitem>
<para>
Узел-элемент <link linkend="book.dom">DOM</link>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>class_name</parameter></term>
<listitem>
<para>
Вы можете использовать этот дополнительный параметр для того, чтобы функция
<function>simplexml_import_dom</function> возвращала объект указанного класса.
Этот класс должен расширять класс <type>SimpleXMLElement</type>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Возвращает <type>SimpleXMLElement</type> или &null; в случае возникновения ошибки.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Импорт DOM</title>
<programlisting role="php">
<![CDATA[
<?php
$dom = new DOMDocument;
$dom->loadXML('<books><book><title>чепуха</title></book></books>');
if (!$dom) {
echo 'Ошибка при разборе документа';
exit;
}
$s = simplexml_import_dom($dom);
echo $s->book[0]->title;
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
чепуха
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>dom_import_simplexml</function></member>
<member><xref linkend="simplexml.examples-basic"/></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->