<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Start parsing an XML document</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.xml-parse-into-struct.html">xml_parse_into_struct</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.xml-parser-create-ns.html">xml_parser_create_ns</a></div> <div class="up"><a href="ref.xml.html">XML Parser Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.xml-parse" class="refentry"> <div class="refnamediv"> <h1 class="refname">xml_parse</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">xml_parse</span> — <span class="dc-title">Start parsing an XML document</span></p> </div> <div class="refsect1 description" id="refsect1-function.xml-parse-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">int</span> <span class="methodname"><strong>xml_parse</strong></span> ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$parser</code></span> , <span class="methodparam"><span class="type">string</span> <code class="parameter">$data</code></span> [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$is_final</code><span class="initializer"> = false</span></span> ] )</div> <p class="para rdfs-comment"> <span class="function"><strong>xml_parse()</strong></span> parses an XML document. The handlers for the configured events are called as many times as necessary. </p> </div> <div class="refsect1 parameters" id="refsect1-function.xml-parse-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">parser</code></em></span> <dd> <p class="para"> A reference to the XML parser to use. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">data</code></em></span> <dd> <p class="para"> Chunk of data to parse. A document may be parsed piece-wise by calling <span class="function"><strong>xml_parse()</strong></span> several times with new data, as long as the <em><code class="parameter">is_final</code></em> parameter is set and <strong><code>TRUE</code></strong> when the last data is parsed. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">is_final</code></em></span> <dd> <p class="para"> If set and <strong><code>TRUE</code></strong>, <em><code class="parameter">data</code></em> is the last piece of data sent in this parse. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.xml-parse-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns 1 on success or 0 on failure. </p> <p class="para"> For unsuccessful parses, error information can be retrieved with <span class="function"><a href="function.xml-get-error-code.html" class="function">xml_get_error_code()</a></span>, <span class="function"><a href="function.xml-error-string.html" class="function">xml_error_string()</a></span>, <span class="function"><a href="function.xml-get-current-line-number.html" class="function">xml_get_current_line_number()</a></span>, <span class="function"><a href="function.xml-get-current-column-number.html" class="function">xml_get_current_column_number()</a></span> and <span class="function"><a href="function.xml-get-current-byte-index.html" class="function">xml_get_current_byte_index()</a></span>. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> Entity errors are reported at the end of the data thus only if <em><code class="parameter">is_final</code></em> is set and <strong><code>TRUE</code></strong>. </p> </p></blockquote> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.xml-parse-into-struct.html">xml_parse_into_struct</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.xml-parser-create-ns.html">xml_parser_create_ns</a></div> <div class="up"><a href="ref.xml.html">XML Parser Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>