<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.simplexml.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'fr',
  ),
  'this' => 
  array (
    0 => 'function.simplexml-load-file.php',
    1 => 'simplexml_load_file',
    2 => 'Convertit un fichier XML en objet',
  ),
  'up' => 
  array (
    0 => 'ref.simplexml.php',
    1 => 'Fonctions SimpleXML',
  ),
  'prev' => 
  array (
    0 => 'function.simplexml-import-dom.php',
    1 => 'simplexml_import_dom',
  ),
  'next' => 
  array (
    0 => 'function.simplexml-load-string.php',
    1 => 'simplexml_load_string',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/simplexml/functions/simplexml-load-file.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.simplexml-load-file" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">simplexml_load_file</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">simplexml_load_file</span> &mdash; <span class="dc-title">Convertit un fichier XML en objet</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.simplexml-load-file-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>simplexml_load_file</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$filename</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$class_name</code><span class="initializer"> = <strong><code>SimpleXMLElement::class</code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$options</code><span class="initializer"> = 0</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$namespace_or_prefix</code><span class="initializer"> = &quot;&quot;</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$is_prefix</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></span></span><br>): <span class="type"><span class="type"><a href="class.simplexmlelement.php" class="type SimpleXMLElement">SimpleXMLElement</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   Convertit le document XML <code class="parameter">filename</code>
   en un objet de type <span class="type"><a href="class.simplexmlelement.php" class="type SimpleXMLElement">SimpleXMLElement</a></span>.
  </p>
 </div>

 
 <div class="refsect1 parameters" id="refsect1-function.simplexml-load-file-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">filename</code></dt>
     <dd>
      <p class="para">
       Chemin vers le fichier XML
      </p>
     </dd>
    
    
     <dt><code class="parameter">class_name</code></dt>
     <dd>
      <p class="para">
       Il est possible d&#039;utiliser ce paramètre optionnel et ainsi,
       la fonction <span class="function"><strong>simplexml_load_file()</strong></span> retournera un objet de
       la classe spécifiée. Cette classe doit étendre la classe 
       <span class="type"><a href="class.simplexmlelement.php" class="type SimpleXMLElement">SimpleXMLElement</a></span>.
      </p>
     </dd>
    
    
     <dt><code class="parameter">options</code></dt>
     <dd>
      <p class="para">
  <a href="language.operators.bitwise.php" class="link">Opération de &#039;OU&#039; logique</a>
  des <a href="libxml.constants.php" class="link">constantes d&#039;option libxml</a>.
</p>
     </dd>
    
    
     <dt><code class="parameter">namespace_or_prefix</code></dt>
     <dd>
      <p class="para">
       Préfixe ou l&#039;URI de l&#039;espace de noms.
      </p>
     </dd>
    
    
     <dt><code class="parameter">is_prefix</code></dt>
     <dd>
      <p class="para">
       <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> si <code class="parameter">namespace_or_prefix</code> est un préfixe,
       <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> si c&#039;est l&#039;URI ; par défaut, <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>

 
 <div class="refsect1 returnvalues" id="refsect1-function.simplexml-load-file-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
   Retourne un <a href="language.types.object.php" class="link">objet</a> de la classe <span class="type"><a href="class.simplexmlelement.php" class="type SimpleXMLElement">SimpleXMLElement</a></span>
   dont les propriétés contiennent les données du document XML,  ou <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> si une erreur survient.
  </p>
  <div class="warning"><strong class="warning">Avertissement</strong><p class="simpara">
 Cette fonction peut retourner <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>, mais elle peut aussi retourner une valeur équivalent à <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
 Veuillez lire la section sur les <a href="language.types.boolean.php" class="link">booléens</a> pour plus d&#039;informations.
 Utilisez l&#039;<a href="language.operators.comparison.php" class="link">opérateur ===</a>
 pour tester la valeur de retour exacte de cette fonction.
</p></div>
 </div>

 
 <div class="refsect1 errors" id="refsect1-function.simplexml-load-file-errors">
  <h3 class="title">Erreurs / Exceptions</h3>
  <p class="para">
   Produit un message d&#039;erreur de niveau <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong>
   pour chaque erreur trouvée dans les données XML.
  </p>
  <div class="tip"><strong class="tip">Astuce</strong>
   <p class="para">
    Utiliser la fonction <span class="function"><a href="function.libxml-use-internal-errors.php" class="function">libxml_use_internal_errors()</a></span>
    pour supprimer toutes les erreurs XML, et la fonction
    <span class="function"><a href="function.libxml-get-errors.php" class="function">libxml_get_errors()</a></span> pour les parcourir.
   </p>
  </div>
 </div>


 <div class="refsect1 examples" id="refsect1-function.simplexml-load-file-examples">
  <h3 class="title">Exemples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Exemple #1 Interprétation d&#039;un document XML</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// Le fichier examples/book.xml contient un document XML avec un élément racine<br />// et au moins un élément /[racine]/title.<br /><br /></span><span style="color: #007700">if (</span><span style="color: #0000BB">file_exists</span><span style="color: #007700">(</span><span style="color: #DD0000">'examples/book.xml'</span><span style="color: #007700">)) {<br />    </span><span style="color: #0000BB">$xml </span><span style="color: #007700">= </span><span style="color: #0000BB">simplexml_load_file</span><span style="color: #007700">(</span><span style="color: #DD0000">'examples/book.xml'</span><span style="color: #007700">);<br /><br />    </span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$xml</span><span style="color: #007700">);<br />} else {<br />    exit(</span><span style="color: #DD0000">'Échec lors de l\'ouverture du fichier examples/test.xml.'</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>
     Ce script affichera, en cas de succès :
    </p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">SimpleXMLElement Object
(
  [book] =&gt; Array
  ...
)</pre>
</div>
    </div>
    <div class="example-contents"><p>
     À partir de là, il est possible d&#039;utiliser <code class="literal">$xml-&gt;title</code>
     et tout autre élément.
    </p></div>
   </div>
  </p>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-function.simplexml-load-file-seealso">
  <h3 class="title">Voir aussi</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.simplexml-load-string.php" class="function" rel="rdfs-seeAlso">simplexml_load_string()</a> - Convertit une cha&icirc;ne XML en objet</span></li>
    <li><span class="methodname"><a href="simplexmlelement.construct.php" class="methodname" rel="rdfs-seeAlso">SimpleXMLElement::__construct()</a> - Cr&eacute;e un nouvel objet SimpleXMLElement</span></li>
    <li><a href="simplexml.examples-errors.php" class="xref">Traitement des erreurs XML</a></li>
    <li><span class="function"><a href="function.libxml-use-internal-errors.php" class="function" rel="rdfs-seeAlso">libxml_use_internal_errors()</a> - D&eacute;sactive le rapport d'erreur libxml et les stocke pour lecture ult&eacute;rieure</span></li>
    <li><a href="simplexml.examples-basic.php" class="xref">Utilisation de base SimpleXML</a></li>
    <li><span class="function"><a href="function.libxml-set-streams-context.php" class="function" rel="rdfs-seeAlso">libxml_set_streams_context()</a> - Configure le contexte de flux pour la prochaine op&eacute;ration libxml</span></li>
   </ul>
  </p>
 </div>

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