1
0
mirror of https://github.com/php/doc-ja.git synced 2026-03-27 16:42:17 +01:00
Files
archived-doc-ja/reference/xml/functions/xml-parse.xml
Yoshinari Takaoka 25cefc6119 XmlParser has been renamed to XMLParser
Although class names are case-insensitive, we better document the proper case.


git-svn-id: https://svn.php.net/repository/phpdoc/ja/trunk@351805 c90b9560-bf6c-de11-be94-00142212c4b1
2020-12-01 01:30:55 +00:00

150 lines
4.6 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 3db49ee0a331a657dd97b539a749f53d3965b593 Maintainer: hirokawa Status: ready -->
<!-- Credits: mumumu -->
<refentry xml:id="function.xml-parse" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>xml_parse</refname>
<refpurpose>XML ドキュメントの処理を開始する</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>int</type><methodname>xml_parse</methodname>
<methodparam><type>XMLParser</type><parameter>parser</parameter></methodparam>
<methodparam><type>string</type><parameter>data</parameter></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>is_final</parameter><initializer>&false;</initializer></methodparam>
</methodsynopsis>
<para>
<function>xml_parse</function> は XML ドキュメントを処理します。
設定されているイベントのハンドラが、必要に応じてコールされます。
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>parser</parameter></term>
<listitem>
<para>
使用する XML パーサへのリファレンス。
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>data</parameter></term>
<listitem>
<para>
処理するデータ。ドキュメントは、
<parameter>is_final</parameter> パラメータが設定され、
最後のデータが処理され &true; になるまで、新規のデータに関して
複数回 <function>xml_parse</function> をコールすることにより、
部分毎で処理することが可能です。
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>is_final</parameter></term>
<listitem>
<para>
&true; が設定された場合、<parameter>data</parameter>
この処理の間に送られた最後のデータということになります。
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
成功した場合に 1、失敗した場合に 0 を返します。
</para>
<para>
処理が成功しなかった場合、エラー情報を
<function>xml_get_error_code</function>,
<function>xml_error_string</function>,
<function>xml_get_current_line_number</function>,
<function>xml_get_current_column_number</function> および
<function>xml_get_current_byte_index</function>
により取得可能です。
</para>
<note>
<para>
エンティティのエラーが報告されるのは、ドキュメントの最後で行われます。
つまり <parameter>is_final</parameter>&true; に設定されている場合だけです。
</para>
</note>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
&xml.changelog.parser-param;
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example xml:id="xml_parse.example.chunked">
<title>巨大なXML文書を切り分けてパースする</title>
<para>
この例は、
どのようにして巨大なXML文書を読み取り、チャンクに分けて
パースするのかを示しています。
これにより、文書全体をメモリに置く必要がないようにします。
エラーハンドリングは例を簡単にするため省略しています。
</para>
<programlisting role="php">
<![CDATA[
<?php
$stream = fopen('large.xml', 'r');
$parser = xml_parser_create();
// ハンドラをセットアップする
while (($data = fread($stream, 16384))) {
xml_parse($parser, $data); // 現在のチャンクをパースする
}
xml_parse($parser, '', true); // パースを終了する
xml_parser_free($parser);
fclose($stream);
]]>
</programlisting>
</example>
</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
-->