1
0
mirror of https://github.com/php/doc-ja.git synced 2026-03-30 11:02:18 +02:00
Files
archived-doc-ja/reference/simplexml/functions/simplexml-load-string.xml
Hideyuki Shimooka 88803ed66c translation updated
git-svn-id: https://svn.php.net/repository/phpdoc/ja/trunk@188756 c90b9560-bf6c-de11-be94-00142212c4b1
2005-06-19 01:55:36 +00:00

109 lines
3.2 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 1.2 $ -->
<!-- EN-Revision: 1.9 Maintainer: hirokawa Status: ready -->
<!-- CREDITS: shimooka -->
<refentry id='function.simplexml-load-string'>
<refnamediv>
<refname>simplexml_load_string</refname>
<refpurpose>
XML文字列をオブジェクトに代入する
</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>object</type><methodname>simplexml_load_string</methodname>
<methodparam><type>string</type><parameter>data</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>class_name</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>options</parameter></methodparam>
</methodsynopsis>
<para>
この関数は、整形式のXML文字列 <parameter>data</parameter> を引数とし、
このXMLドキュメントに保持されたデータを含むプロパティを有する
<type>SimpleXMLElement</type> クラスのオブジェクトを返します。
エラーが発生した場合、この関数は &false; を返します。
</para>
<para>
<function>simplexml_load_file</function>
が指定されたクラスのオブジェクトを返すようにするためにオプションの
<parameter>class_name</parameter> パラメータを使用することができます。
そのクラスは、<type>SimpleXMLElement</type>
クラスを継承していなければなりません。
</para>
<para>
PHP 5.1.0 と Libxml 2.6.0 から、<link
linkend="libxml.constants">追加の Libxml パラメータ</link>
を指定するために <parameter>options</parameter>
を使用することもできます。
</para>
<para>
<example>
<title>XML文字列をパースする</title>
<programlisting role="php">
<![CDATA[
<?php
$string = <<<XML
<?xml version='1.0'?>
<document>
<title>Forty What?</title>
<from>Joe</from>
<to>Jane</to>
<body>
I know that's the answer -- but what's the question?
</body>
</document>
XML;
$xml = simplexml_load_string($string);
var_dump($xml);
?>
]]>
</programlisting>
<para>
This script will display:
</para>
<screen>
<![CDATA[
SimpleXMLElement Object
(
[title] => Forty What?
[from] => Joe
[to] => Jane
[body] =>
I know that's the answer -- but what's the question?
)
]]>
</screen>
<simpara>
この時点で、<literal>$xml->body</literal>のようにアクセスすることができます。
</simpara>
</example>
</para>
<para>
<function>simplexml_load_file</function>も参照してください。
</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:"../../../../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
-->