1
0
mirror of https://github.com/php/doc-ru.git synced 2026-03-26 08:42:13 +01:00
Files
archived-doc-ru/reference/simplexml/simplexmlelement/construct.xml
Mikhail Alferov ebff5adf4d Updated to English (#963)
* Update constants.xml

* Update new-features.xml

* Update book.xml

* Update evstat.xml

* Update construct.xml

* Update ini.xml

* Update book.xml

* Update controls.xml

* Update ldap-exop.xml

* Update pattern.modifiers.xml

* Update pattern.modifiers.xml

* Update construct.xml

* Update construct.xml

* Update sodium-crypto-pwhash.xml

* Update book.xml

* Update close.xml

* Update getarchiveflag.xml

* Update open.xml

* Update setarchiveflag.xml
2024-03-18 09:45:48 +03:00

187 lines
6.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: 28f0dc949d62c97698ac4a0ca814c3780d8cf318 Maintainer: mch Status: ready -->
<!-- Reviewed: no -->
<refentry xml:id="simplexmlelement.construct" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>SimpleXMLElement::__construct</refname>
<refpurpose>
Создаёт новый объект SimpleXMLElement
</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<constructorsynopsis role="SimpleXMLElement">
<modifier>public</modifier> <methodname>SimpleXMLElement::__construct</methodname>
<methodparam><type>string</type><parameter>data</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>options</parameter><initializer>0</initializer></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>dataIsURL</parameter><initializer>&false;</initializer></methodparam>
<methodparam choice="opt"><type>string</type><parameter>namespaceOrPrefix</parameter><initializer>""</initializer></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>isPrefix</parameter><initializer>&false;</initializer></methodparam>
</constructorsynopsis>
<para>
Создаёт новый объект <classname>SimpleXMLElement</classname>.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>data</parameter></term>
<listitem>
<para>
Правильно сформированная XML-строка, путь или URL к XML-документу,
если значение параметра <parameter>dataIsURL</parameter> равно &true;.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>options</parameter></term>
<listitem>
<para>
Необязательный параметр, определяет
<link linkend="libxml.constants">дополнительные параметры модуля Libxml</link>,
которые влияют на чтение XML-документов. Параметры, которые влияют на вывод
XML-документов (например, <constant>LIBXML_NOEMPTYTAG</constant>),
без предупреждения игнорируются.
</para>
<note>
<para>
Когда нужна обработка XML-документа с глубокой вложенностью или большого текстового узла,
передают константу <constant>LIBXML_PARSEHUGE</constant>.
</para>
</note>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>dataIsURL</parameter></term>
<listitem>
<para>
По умолчанию для параметра <parameter>dataIsURL</parameter> установлено значение &false;.
Используйте &true;, чтобы указать, что данные <parameter>data</parameter>
путь или URL к XML-документу, а не данные с типом <type>string</type>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>namespaceOrPrefix</parameter></term>
<listitem>
<para>
Префикс пространства имён или URI.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>isPrefix</parameter></term>
<listitem>
<para>
Значение &true;, если значение параметра <parameter>namespaceOrPrefix</parameter> — префикс,
&false;, если это URI; по умолчанию — &false;.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
<para>
Метод выдаёт сообщение об ошибке уровня <constant>E_WARNING</constant> для каждой ошибки,
которую метод нашёл в XML-данных, и дополнительно выбрасывает исключение <classname>Exception</classname>,
если данные XML невозможно разобрать.
</para>
<tip>
<para>
Для подавления XML-ошибок вызывают функцию <function>libxml_use_internal_errors</function>,
а для дальнейшей итерации по ошибкам — <function>libxml_get_errors</function>.
</para>
</tip>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<note>
<para>
Перечисленные примеры могут включать файл <literal>example.php</literal>,
который содержит XML-строку, найденную в первом примере
краткого руководства
<link linkend="simplexml.examples-basic">по основам работы с модулем SimpleXML</link>.
</para>
</note>
<example>
<title>Создание объекта SimpleXMLElement</title>
<programlisting role="php">
<![CDATA[
<?php
include 'example.php';
$sxe = new SimpleXMLElement($xmlstr);
echo $sxe->movie[0]->title;
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
PHP: Появление Парсера
]]>
</screen>
</example>
</para>
<para>
<example>
<title>Создание объекта SimpleXMLElement из URL-адреса</title>
<programlisting role="php">
<![CDATA[
<?php
$sxe = new SimpleXMLElement('http://example.org/document.xml', 0, true);
echo $sxe->asXML();
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><xref linkend="simplexml.examples-basic"/></member>
<member><function>simplexml_load_string</function></member>
<member><function>simplexml_load_file</function></member>
<member><xref linkend="simplexml.examples-errors"/></member>
<member><function>libxml_use_internal_errors</function></member>
<member><function>libxml_set_streams_context</function></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
-->