<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.simplexml.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'ru',
  ),
  'this' => 
  array (
    0 => 'function.simplexml-load-string.php',
    1 => 'simplexml_load_string',
    2 => 'Интерпретирует строку в XML-формате в объект',
  ),
  'up' => 
  array (
    0 => 'ref.simplexml.php',
    1 => 'Функции SimpleXML',
  ),
  'prev' => 
  array (
    0 => 'function.simplexml-load-file.php',
    1 => 'simplexml_load_file',
  ),
  'next' => 
  array (
    0 => 'book.wddx.php',
    1 => 'WDDX',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ru',
    'path' => 'reference/simplexml/functions/simplexml-load-string.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.simplexml-load-string" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">simplexml_load_string</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">simplexml_load_string</span> &mdash; <span class="dc-title">
   Интерпретирует строку в XML-формате в объект
  </span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.simplexml-load-string-description">
  <h3 class="title">Описание</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>simplexml_load_string</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"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$class_name</code><span class="initializer"> = <strong><code>SimpleXMLElement::class</code></strong></span></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.string.php" class="type string">string</a></span> <code class="parameter">$namespace_or_prefix</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">$is_prefix</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></span></span><br>): <span class="type"><span class="type"><a href="class.simplexmlelement.php" class="type SimpleXMLElement">SimpleXMLElement</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   Функция получает правильно сформированную XML-строку и возвращает строку как объект.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.simplexml-load-string-parameters">
  <h3 class="title">Список параметров</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">data</code></dt>
     <dd>
      <p class="para">
       Правильно сформированная XML-строка.
      </p>
     </dd>
    
    
     <dt><code class="parameter">class_name</code></dt>
     <dd>
      <p class="para">
       Необязательный параметр, который заставляет функцию
       <span class="function"><strong>simplexml_load_string()</strong></span> возвращать объект конкретного класса,
       который расширяет класс <span class="type"><a href="class.simplexmlelement.php" class="type SimpleXMLElement">SimpleXMLElement</a></span>.
      </p>
     </dd>
    
    
     <dt><code class="parameter">options</code></dt>
     <dd>
      <p class="para">
 <a href="language.operators.bitwise.php" class="link">Побитовое ИЛИ (<code class="literal">OR</code>)</a>
 <a href="libxml.constants.php" class="link">констант опций libxml</a>.
</p>
     </dd>
    
    
     <dt><code class="parameter">namespace_or_prefix</code></dt>
     <dd>
      <p class="para">
       Префикс пространства имён или URI-идентификатор.
      </p>
     </dd>
    
    
     <dt><code class="parameter">is_prefix</code></dt>
     <dd>
      <p class="para">
       В параметр передают значение <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>, если в аргументе
       <code class="parameter">namespace_or_prefix</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 returnvalues" id="refsect1-function.simplexml-load-string-returnvalues">
  <h3 class="title">Возвращаемые значения</h3>
  <p class="para">
   Функция возвращает объект (<span class="type"><a href="language.types.object.php" class="type object">object</a></span>) класса <span class="type"><a href="class.simplexmlelement.php" class="type SimpleXMLElement">SimpleXMLElement</a></span>
   со свойствами, которые содержат данные, которые хранятся внутри XML-документа, или <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>, если возникла ошибка.
  </p>
  <div class="warning"><strong class="warning">Внимание</strong><p class="simpara">Функция
возвращает как логическое значение <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>,
так и нелогическое значение, которое приводится к <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
Прочитайте раздел
«<a href="language.types.boolean.php" class="link">Логический тип</a>»,
чтобы получить дополнительную информацию.
Используйте <a href="language.operators.comparison.php" class="link">оператор ===</a>
для проверки значения, которое возвращает функция.</p></div>

 </div>


 <div class="refsect1 errors" id="refsect1-function.simplexml-load-string-errors">
  <h3 class="title">Ошибки</h3>
  <p class="para">
   Функция генерирует сообщение об ошибке уровня <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong>
   для каждой ошибки, которую нашла в XML-данных.
  </p>
  <div class="tip"><strong class="tip">Подсказка</strong>
   <p class="para">
    Для подавления ошибок в XML-данных вызывают функцию
    <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-function.simplexml-load-string-examples">
  <h3 class="title">Примеры</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Пример #1 Пример интерпретации XML-строки</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />$string </span><span style="color: #007700">= &lt;&lt;&lt;XML<br /></span><span style="color: #DD0000">&lt;?xml version='1.0'?&gt;<br />&lt;document&gt;<br /> &lt;title&gt;Что 40?&lt;/title&gt;<br /> &lt;from&gt;Джо&lt;/from&gt;<br /> &lt;to&gt;Джейн&lt;/to&gt;<br /> &lt;body&gt;<br />  Я знаю, что это - ответ. В чем заключается вопрос?<br /> &lt;/body&gt;<br />&lt;/document&gt;<br /></span><span style="color: #007700">XML;<br /><br /></span><span style="color: #0000BB">$xml </span><span style="color: #007700">= </span><span style="color: #0000BB">simplexml_load_string</span><span style="color: #007700">(</span><span style="color: #0000BB">$string</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$xml</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">SimpleXMLElement Object
(
  [title] =&gt; Что 40?
  [from] =&gt; Джо
  [to] =&gt; Джейн
  [body] =&gt;
   Я знаю, что это - ответ. В чем заключается вопрос?
)</pre>
</div>
    </div>
    <div class="example-contents"><p>
     После интерпретации строки в XML-формате в объект возможны обращения
     к XML-элементам синтаксисом <code class="literal">$xml-&gt;body</code>
     и вызовы методов объекта.
    </p></div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.simplexml-load-string-seealso">
  <h3 class="title">Смотрите также</h3>
  <p class="para">
   <ul class="simplelist">
    <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><span class="methodname"><a href="simplexmlelement.construct.php" class="methodname" rel="rdfs-seeAlso">SimpleXMLElement::__construct()</a> - Создаёт новый объект SimpleXMLElement</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><a href="simplexml.examples-basic.php" class="xref">Основы работы с модулем SimpleXML</a></li>
   </ul>
  </p>
 </div>

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