aRo`

automating your e-commerce

To capture the encoding from the XML tag of the file. We need to read the first line, and pass it to the function to capture the encoding value.
The first line looks like this:
< ?xml version="1.0" encoding="utf-8"? >

The PHP code:
PLAIN TEXT
PHP:

function readfirstline($file){

   $fp = @fopen($file, "r");

   $firstline = fgets($fp);

   fclose($fp);

   return $firstline;

function get_attr(  $line [...]

This little php functions shows how to write the recursive XMLpath for all nodes that contain values.
PLAIN TEXT
XML:

$xmlstr = <<<XML

<?xml version='1.0' standalone='yes'?>

<movies>

 <movie>

  <title>PHP: Behind the Parser</title>

  <characters>

   <character>

    <name>Ms. Coder</name>

    <actor>Onlivia Actora</actor>

   </character>

   <character>

    <name>Mr. Coder</name>

    <actor>El Act&#211;r</actor>

   </character>

  </characters>

  <plot>

   So, this language. It's like, a programming language. Or is [...]