<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.simplexmlelement.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'ru',
  ),
  'this' => 
  array (
    0 => 'simplexmlelement.construct.php',
    1 => 'SimpleXMLElement::__construct',
    2 => 'Создаёт новый объект SimpleXMLElement',
  ),
  'up' => 
  array (
    0 => 'class.simplexmlelement.php',
    1 => 'SimpleXMLElement',
  ),
  'prev' => 
  array (
    0 => 'simplexmlelement.children.php',
    1 => 'SimpleXMLElement::children',
  ),
  'next' => 
  array (
    0 => 'simplexmlelement.count.php',
    1 => 'SimpleXMLElement::count',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ru',
    'path' => 'reference/simplexml/simplexmlelement/construct.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="simplexmlelement.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SimpleXMLElement::__construct</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">SimpleXMLElement::__construct</span> &mdash; <span class="dc-title">
   Создаёт новый объект SimpleXMLElement
  </span></p>

 </div>
 <div class="refsect1 description" id="refsect1-simplexmlelement.construct-description">
  <h3 class="title">Описание</h3>
  <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>SimpleXMLElement::__construct</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$data</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$options</code><span class="initializer"> = 0</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$dataIsURL</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$namespaceOrPrefix</code><span class="initializer"> = &quot;&quot;</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$isPrefix</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></span></span><br>)</div>

  <p class="para rdfs-comment">
   Метод создаёт новый объект <span class="classname"><a href="class.simplexmlelement.php" class="classname">SimpleXMLElement</a></span>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-simplexmlelement.construct-parameters">
  <h3 class="title">Список параметров</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">data</code></dt>
     <dd>
      <p class="para">
       Правильно сформированная XML-строка, путь или URL к XML-документу,
       если значение параметра <code class="parameter">dataIsURL</code> равно <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>.
      </p>
     </dd>
    
    
     <dt><code class="parameter">options</code></dt>
     <dd>
      <p class="para">
       Необязательный параметр, определяет
       <a href="libxml.constants.php" class="link">дополнительные параметры модуля Libxml</a>,
       которые влияют на чтение XML-документов. Параметры, которые влияют на вывод
       XML-документов (например, <strong><code><a href="libxml.constants.php#constant.libxml-noemptytag">LIBXML_NOEMPTYTAG</a></code></strong>),
       без предупреждения игнорируются.
      </p>
      <blockquote class="note"><p><strong class="note">Замечание</strong>: 
       <p class="para">
        Когда нужна обработка XML-документа с глубокой вложенностью или большого текстового узла,
        передают константу <strong><code><a href="libxml.constants.php#constant.libxml-parsehuge">LIBXML_PARSEHUGE</a></code></strong>.
       </p>
      </p></blockquote>
     </dd>
    
    
     <dt><code class="parameter">dataIsURL</code></dt>
     <dd>
      <p class="para">
       Значение параметра <code class="parameter">dataIsURL</code> по умолчанию равно <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
       Значение <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> указывает, что данные в параметре <code class="parameter">data</code> —
       путь или URL-адрес к XML-документу, а не данные с типом <span class="type"><a href="language.types.string.php" class="type string">string</a></span>.
      </p>
     </dd>
    
    
     <dt><code class="parameter">namespaceOrPrefix</code></dt>
     <dd>
      <p class="para">
       Префикс пространства имён или URI.
      </p>
     </dd>
    
    
     <dt><code class="parameter">isPrefix</code></dt>
     <dd>
      <p class="para">
       При установке значения <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> метод интерпретирует значение
       параметра <code class="parameter">namespaceOrPrefix</code> как префикс,
       а со значением <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> — как URI; значение по умолчанию равно <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-simplexmlelement.construct-errors">
  <h3 class="title">Ошибки</h3>
  <p class="para">
   Метод выдаёт сообщение об ошибке уровня <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong> для каждой ошибки,
   которую метод нашёл в XML-данных, и дополнительно выбрасывает исключение <span class="classname"><a href="class.exception.php" class="classname">Exception</a></span>,
   если XML-данные невозможно разобрать.
  </p>
  <div class="tip"><strong class="tip">Подсказка</strong>
   <p class="para">
    Функция <span class="function"><a href="function.libxml-use-internal-errors.php" class="function">libxml_use_internal_errors()</a></span> подавляет ошибки,
    а функция <span class="function"><a href="function.libxml-get-errors.php" class="function">libxml_get_errors()</a></span> возвращает список ошибок для обработки.
   </p>
  </div>
 </div>


 <div class="refsect1 examples" id="refsect1-simplexmlelement.construct-examples">
  <h3 class="title">Примеры</h3>
  <p class="para">
   <blockquote class="note"><p><strong class="note">Замечание</strong>: 
    <p class="para">
     В следующем примере включается файл <code class="literal">examples/simplexml-data.php</code>
     с определением XML-строки из первого примера руководства
     «<a href="simplexml.examples-basic.php" class="link">Основы работы с модулем SimpleXML</a>».
    </p>
   </p></blockquote>
   <div class="example" id="example-1">
    <p><strong>Пример #1 Пример создания объекта SimpleXMLElement</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">include </span><span style="color: #DD0000">'examples/simplexml-data.php'</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$sxe </span><span style="color: #007700">= new </span><span style="color: #0000BB">SimpleXMLElement</span><span style="color: #007700">(</span><span style="color: #0000BB">$xmlstr</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$sxe</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">movie</span><span style="color: #007700">[</span><span style="color: #0000BB">0</span><span style="color: #007700">]-&gt;</span><span style="color: #0000BB">title</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    
<div class="example-contents"><p>
 Результат выполнения приведённого примера:
</p></div>

    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">PHP: Появление Парсера</pre>
</div>
    </div>
   </div>
  </p>
  <p class="para">
   <div class="example" id="example-2">
    <p><strong>Пример #2 Пример создания объекта SimpleXMLElement из URL-адреса</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />$sxe </span><span style="color: #007700">= new </span><span style="color: #0000BB">SimpleXMLElement</span><span style="color: #007700">(</span><span style="color: #DD0000">'http://example.org/document.xml'</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">true</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$sxe</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">asXML</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-simplexmlelement.construct-seealso">
  <h3 class="title">Смотрите также</h3>
  <p class="para">
   <ul class="simplelist">
    <li><a href="simplexml.examples-basic.php" class="xref">Основы работы с модулем SimpleXML</a></li>
    <li><span class="function"><a href="function.simplexml-load-string.php" class="function" rel="rdfs-seeAlso">simplexml_load_string()</a> - Интерпретирует строку в XML-формате в объект</span></li>
    <li><span class="function"><a href="function.simplexml-load-file.php" class="function" rel="rdfs-seeAlso">simplexml_load_file()</a> - Интерпретирует XML-файл и преобразовывает XML-документ в объект</span></li>
    <li><a href="simplexml.examples-errors.php" class="xref">Обработка ошибок в XML-документах</a></li>
    <li><span class="function"><a href="function.libxml-use-internal-errors.php" class="function" rel="rdfs-seeAlso">libxml_use_internal_errors()</a> - Отключение ошибок libxml и передача полномочий по выборке и обработке
   информации об ошибках пользователю</span></li>
    <li><span class="function"><a href="function.libxml-set-streams-context.php" class="function" rel="rdfs-seeAlso">libxml_set_streams_context()</a> - Устанавливает контекст потоков для следующей загрузки или записи
   документа средствами модуля libxml</span></li>
   </ul>
  </p>
 </div>

</div><?php manual_footer($setup); ?>