There is an xml file:

<?xml version = "1.0" encoding = "utf-8"?> <workers> <worker> <name>Ivan</name> <color>Tomato</color> </worker> </workers> 

And there is a php file:

  <?php $xml = simplexml_load_file("worrrkers.xml") or die("Error: Cannot create object"); foreach($xml->children() as $worrrkers) { echo $worrrkers->name . "<br> "; echo $worrrkers->color . "<hr> "; } ?> 

How to display the name of the employee in the colors specified in xml? By its html name or by code, n # 0040ff.

    1 answer 1

    In the Color field you enter # 0040ff, And on the screen you output as follows:

     echo '<span style="color:'.$worrrkers->color.'">'.$worrrkers->name.'</span>'; 
    • Name colors work too - Walfter
    • @Walfter, I do not deny. But in practice, it is all the same that use HEX, RGB or RGBA. - Andrey