Change of xml content by using php

Hi all,

I currently have following problem:

I want to load the xml file for the grid and change some xml entries depending on user settings.

This means, I have a user identified who is loading the grid and depending on this user, for example of his last visit time, which is stored in a sql database, I want to make some entries of the grid in red color.

If another user, with another visiting time loads the grid, other entries would be colored.

I was tinking of loading the xml into a php “variable” and then make the modificiation neccessary of the “xml variable content”. After that I want to handover this xml variable as input for the grid.

Is that possible or is there another more easier way to establish this kind of user depended grid view?



Are you storing data of grid as static XML or building it form database ?
I first case the only way it to load and modify XML on the fly , you can use


where some.php
- read xml file |
- modify it in necessary way
- echo modified xml

as result grid will loaded modified data.

If you are loading data from DB - you can just generated XML with necessary styling assigned and output it to client side in the same manner
( by the way, you can look at connectors lib - … ndex.shtml )

thanks for your quick reply.
I’m storing the data in a static xml file.
I will try your hint by loading it with “some.php” :slight_smile:


Be sure to have next order of commands in PHP file

header(“Content-type:text/xml”); //this line is mandatory!
echo $processed_data;

Hi again,
yes, simple loading like this

$filename = ‘news.xml’;
$data = file_get_contents($filename,‘r’);
echo $data;

is working now.

Unfortunatly I dont see the possibility to really address direct an element, because they are all called “cell”.
My xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>


08:59 UTC]]>

What I want to do now, is that the cell
08:59 UTC]]>
gets another font attribute if the date in this cell is later than a specific time.

Or do I need to use a function like “simplexml_load_file” or something like this?
Any idea?

If you know, exact text of the cell you can use strreplace or preg_replace to change original value of strings to another one.
If exact text unknown - you will need to parse XML ( simpleXML or XMLDom ) and use XPath to locate and replace necessary XML element

Finally many thanks for your great support!
I did it the way you supposed. Working fine now! :slight_smile:


* Thread Closed *