Hello,

My question is a bit theoreric at the moment.
I have a XML file that contains some data, i would like to know if it is possible to write a PHP page that reads the XML file, and if he recognizes a spesific string in the XML file, he updates a HTML file with that string.

Is this possible do to using PHP ? i know that PHP can read a XML file, but can he update a spesific line within a HTML file as well.

Thanks in advance.

I'm no pro at manipulating XML with PHP, but reading up on the DOM extension may be helpful. You should be able to grab the element you want from the XML, do any further processing you want to, then grab the element you want from the HTML and modify it as needed.

@EvolutionFallen, so in principle i can modify a HTML page by using PHP.

That's what I've hopped for.

Absolutely. You can even simply put PHP code right into a .html file, you just need to change your .htaccess to tell Apache it should process PHP found in .htmls.

Member Avatar
diafol

You have many approaches open to you, depending on what exactly you need to do. For example, are the html files already created and not allowed to be edited?

You could use a "template" to produce a dynamic page. There are native php functions you could use to do this or you could use a lightweight templating engine such as RainTPL or Twig. If you could rename your .html pages to .php then you wouldn't have to mess with your .htaccess files.