lectura de XML desde un string - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.

Name: lectura de XML desde un string fullscreencopyrawdownloadembedprint


Your result can be seen below.

Result of php executing





Full code of lectura de XML desde un string.php

  1. <?php
  2. $dirXML ='<?xml version="1.0" encoding="iso-8859-1"?>
  3. <DTE version="1.0">
  4.     <Documento ID="T15433">
  5.         <TED version="1.0">
  6.             <DD>
  7.                 <CAF version="1.0">
  8.                     <DA>
  9.                         <RE>70064202-K</RE>
  10.                         <RS>JUNTA DE ALCALDES PROVIDENCIA LAS CONDES</RS>
  11.                         <TD>39</TD>
  12.                         <RNG>
  13.                             <D>10001</D>
  14.                             <H>20000</H>
  15.                         </RNG>
  16.                         <FA>2021-03-10</FA>
  17.                         <IDK>300</IDK>
  18.                     </DA>
  19.                 </CAF>
  20.             </DD>
  21.         </TED>
  22.     </Documento>
  23. </DTE>';
  24.  
  25. $cont = simplexml_load_string($dirXML);
  26. echo '<pre>';
  27. echo var_dump($cont->Documento->TED->DD->CAF->DA->RNG);
  28. echo var_dump($cont);
  29. echo '</pre>';
File Description
  • lectura de XML desde un string
  • PHP Code
  • 17 Jun-2021
  • 849 Bytes
You can Share it: