mirror of
https://github.com/php/doc-ja.git
synced 2026-03-24 15:12:22 +01:00
189 lines
5.9 KiB
XML
189 lines
5.9 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: takagi Status: ready -->
|
|
<!-- Credits: mumumu -->
|
|
<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 文字列。
|
|
もし <parameter>dataIsURL</parameter> が &true;
|
|
の場合には、XML ドキュメントへのパスあるいは URL。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>options</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
オプションで、XML文書を読み込む場合に影響する <link linkend="libxml.constants">追加の
|
|
Libxml パラメータ</link>を指定するために使います。
|
|
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; です。
|
|
<parameter>data</parameter> が、文字列データではなく
|
|
XML ドキュメントへのパスあるいは URL である場合に
|
|
&true; を使用します。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>namespaceOrPrefix</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
名前空間プレフィックスあるいは URI。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>isPrefix</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
<parameter>namespaceOrPrefix</parameter> がプレフィックスの場合は &true;、
|
|
URI の場合は &false;。デフォルトは &false;。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="errors">
|
|
&reftitle.errors;
|
|
<para>
|
|
XML データ内でエラーが見つかるたびに <constant>E_WARNING</constant>
|
|
エラーメッセージが発生します。さらに、XML データのパースに失敗した場合は例外をスローします。
|
|
</para>
|
|
<tip>
|
|
<para>
|
|
<function>libxml_use_internal_errors</function> ですべての XML エラーを抑制し、
|
|
後から <function>libxml_get_errors</function> で取得することもできます。
|
|
</para>
|
|
</tip>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<note>
|
|
<para>
|
|
この例では <literal>examples/simplexml-data.php</literal>
|
|
をインクルードしていますが、これは
|
|
<link linkend="simplexml.examples-basic">基本的な使用法</link>
|
|
の最初のサンプルにある XML 文字列を参照しています。
|
|
</para>
|
|
</note>
|
|
<example>
|
|
<title>SimpleXMLElement オブジェクトの作成</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
include 'examples/simplexml-data.php';
|
|
|
|
$sxe = new SimpleXMLElement($xmlstr);
|
|
echo $sxe->movie[0]->title;
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
PHP: Behind the Parser
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>URL からの SimpleXMLElement オブジェクトの作成</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
|
|
-->
|