<?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 => 'ja',
  ),
  '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' => 'ja',
    '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 文字列。
       もし <code class="parameter">dataIsURL</code> が <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>
       の場合には、XML ドキュメントへのパスあるいは URL。
      </p>
     </dd>
    
    
     <dt><code class="parameter">options</code></dt>
     <dd>
      <p class="para">
       オプションで、XML文書を読み込む場合に影響する <a href="libxml.constants.php" class="link">追加の
       Libxml パラメータ</a>を指定するために使います。
       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> です。
       <code class="parameter">data</code> が、文字列データではなく
       XML ドキュメントへのパスあるいは URL である場合に
       <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> を使用します。
      </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">
       <code class="parameter">namespaceOrPrefix</code> がプレフィックスの場合は <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>、
       URI の場合は <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>。
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-simplexmlelement.construct-errors">
  <h3 class="title">エラー / 例外</h3>
  <p class="para">
   XML データ内でエラーが見つかるたびに <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">
    <span class="function"><a href="function.libxml-use-internal-errors.php" class="function">libxml_use_internal_errors()</a></span> ですべての XML エラーを抑制し、
    後から <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>
     をインクルードしていますが、これは
     <a href="simplexml.examples-basic.php" class="link">基本的な使用法</a>
     の最初のサンプルにある XML 文字列を参照しています。
    </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: Behind the Parser</pre>
</div>
    </div>
   </div>
  </p>
  <p class="para">
   <div class="example" id="example-2">
    <p><strong>例2 URL からの 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 />$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ファイルをパースし、オブジェクトに代入する</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); ?>