<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.xml.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'function.xml-set-element-handler.php',
    1 => 'xml_set_element_handler',
    2 => 'Set up start and end element handlers',
  ),
  'up' => 
  array (
    0 => 'ref.xml.php',
    1 => 'XML Parser Functions',
  ),
  'prev' => 
  array (
    0 => 'function.xml-set-default-handler.php',
    1 => 'xml_set_default_handler',
  ),
  'next' => 
  array (
    0 => 'function.xml-set-end-namespace-decl-handler.php',
    1 => 'xml_set_end_namespace_decl_handler',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/xml/functions/xml-set-element-handler.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.xml-set-element-handler" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">xml_set_element_handler</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">xml_set_element_handler</span> &mdash; <span class="dc-title">Set up start and end element handlers</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.xml-set-element-handler-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>xml_set_element_handler</strong></span>(<span class="methodparam"><span class="type"><a href="class.xmlparser.php" class="type XMLParser">XMLParser</a></span> <code class="parameter">$parser</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span>|<span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.null.php" class="type null">null</a></span></span> <code class="parameter">$start_handler</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span>|<span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.null.php" class="type null">null</a></span></span> <code class="parameter">$end_handler</code></span>): <span class="type"><a href="language.types.singleton.php" class="type true">true</a></span></div>

  <p class="para rdfs-comment">
   Sets the element handler functions for the XML <code class="parameter">parser</code>.
  </p>
  <p class="para">
   <code class="parameter">start_handler</code> is called when a new XML element is
   opened. <code class="parameter">end_handler</code> is called when an XML element
   is closed.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.xml-set-element-handler-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>
    
 <dt><code class="parameter">parser</code></dt>
 <dd>
  <p class="para">
   The XML parser.
  </p>
 </dd>

    
     <dt><code class="parameter">start_handler</code></dt>
     <dd>
      <p class="para">
 If <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> is passed, the handler is reset to its default state.
 <div class="warning"><strong class="warning">Warning</strong>
  <p class="simpara">
    An empty string will also reset the handler,
    however this is deprecated as of PHP 8.4.0.
  </p>
 </div>
</p>
<p class="para">
 If <code class="parameter">handler</code> is a <span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span>,
 the callable is set as the handler.
</p>
<p class="para">
 If <code class="parameter">handler</code> is a <span class="type"><a href="language.types.string.php" class="type string">string</a></span>,
 it can be the name of a method of an object set with
 <span class="function"><a href="function.xml-set-object.php" class="function">xml_set_object()</a></span>.
 <div class="warning"><strong class="warning">Warning</strong>
  <p class="simpara">
   This is deprecated as of PHP 8.4.0.
  </p>
 </div>
</p>
<div class="warning"><strong class="warning">Warning</strong>
 <p class="simpara">
  As of PHP 8.4.0, the callable is checked to be valid while setting the handler,
  not when it is called.
  This means that <span class="function"><a href="function.xml-set-object.php" class="function">xml_set_object()</a></span> must be called prior to
  setting a method string as the callback.
  However, as this behaviour is also deprecated as of PHP 8.4.0,
  using a proper <span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> for the method is recommended instead.
 </p>
</div>

      <p class="para">
       The signature of the handler must be:
       <div class="methodsynopsis dc-description"><span class="methodname"><span class="replaceable">start_element_handler</span></span>(<span class="methodparam"><span class="type"><a href="class.xmlparser.php" class="type XMLParser">XMLParser</a></span> <code class="parameter">$parser</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$name</code></span>, <span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$attributes</code></span>): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>

       <dl>
        
 <dt><code class="parameter">parser</code></dt>
 <dd>
  <span class="simpara">
   The XML parser calling the handler.
  </span>
 </dd>

        
         <dt><code class="parameter">name</code></dt>
         <dd>
          <span class="simpara">
           Contains the name of the element for which this handler is called.
           If <a href="xml.case-folding.php" class="link">case-folding</a> is in effect
           for this parser, the element name will be in uppercase letters.
          </span>
         </dd>
        
        
         <dt><code class="parameter">attributes</code></dt>
         <dd>
          <span class="simpara">
           An associative array with the element&#039;s attributes.
           The array is empty if the element has no attributes.
           The keys of this array are the attribute names,
           the values are the attribute values.
           Attribute names are
           <a href="xml.case-folding.php" class="link">case-folded</a>
           on the same criteria as element names.
           Attribute values are <em>not</em> case-folded.
          </span>
          <span class="simpara">
           The order in which <code class="parameter">attributes</code> is traversed
           is identical to the order in which the attributes were declared.
          </span>
         </dd>
        
       </dl>
      </p>
     </dd>
    
    
     <dt><code class="parameter">end_handler</code></dt>
     <dd>
      <p class="para">
 If <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> is passed, the handler is reset to its default state.
 <div class="warning"><strong class="warning">Warning</strong>
  <p class="simpara">
    An empty string will also reset the handler,
    however this is deprecated as of PHP 8.4.0.
  </p>
 </div>
</p>
<p class="para">
 If <code class="parameter">handler</code> is a <span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span>,
 the callable is set as the handler.
</p>
<p class="para">
 If <code class="parameter">handler</code> is a <span class="type"><a href="language.types.string.php" class="type string">string</a></span>,
 it can be the name of a method of an object set with
 <span class="function"><a href="function.xml-set-object.php" class="function">xml_set_object()</a></span>.
 <div class="warning"><strong class="warning">Warning</strong>
  <p class="simpara">
   This is deprecated as of PHP 8.4.0.
  </p>
 </div>
</p>
<div class="warning"><strong class="warning">Warning</strong>
 <p class="simpara">
  As of PHP 8.4.0, the callable is checked to be valid while setting the handler,
  not when it is called.
  This means that <span class="function"><a href="function.xml-set-object.php" class="function">xml_set_object()</a></span> must be called prior to
  setting a method string as the callback.
  However, as this behaviour is also deprecated as of PHP 8.4.0,
  using a proper <span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> for the method is recommended instead.
 </p>
</div>

      <p class="para">
       The signature of the handler must be:
       <div class="methodsynopsis dc-description"><span class="methodname"><span class="replaceable">end_element_handler</span></span>(<span class="methodparam"><span class="type"><a href="class.xmlparser.php" class="type XMLParser">XMLParser</a></span> <code class="parameter">$parser</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$name</code></span>): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>

       <dl>
        
 <dt><code class="parameter">parser</code></dt>
 <dd>
  <span class="simpara">
   The XML parser calling the handler.
  </span>
 </dd>

        
         <dt><code class="parameter">name</code></dt>
         <dd>
          <span class="simpara">
           Contains the name of the element for which this handler is called.
           If <a href="xml.case-folding.php" class="link">case-folding</a> is in effect
           for this parser, the element name will be in uppercase letters.
          </span>
         </dd>
        
       </dl>
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.xml-set-element-handler-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Always returns <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.xml-set-element-handler-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Description</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
 <td>8.4.0</td>
 <td>
  Passing a non-<span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> <span class="type"><a href="language.types.string.php" class="type string">string</a></span> to
  <code class="parameter">handler</code> is now deprecated,
  use a proper callable for methods, or <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> to reset the handler.
 </td>
</tr>

<tr>
 <td>8.4.0</td>
 <td>
  The validity of <code class="parameter">handler</code> as a <span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span>
  is now checked when setting the handler instead of checking when calling it.
 </td>
</tr>

     <tr>
 <td>8.0.0</td>
 <td>
  <code class="parameter">parser</code> expects an <span class="classname"><a href="class.xmlparser.php" class="classname">XMLParser</a></span>
  instance now; previously, a valid <code class="literal">xml</code> <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> was expected.
 </td>
</tr>

    </tbody>
   
  </table>

 </div>


</div><?php manual_footer($setup); ?>