Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- How to call a class function from XML
October 3, 2007, 7:44 pm
rate this thread
<div id="displayDivOne" src="mkNav()" />
I want to use the div line to call a class function, I.E. $this-
without creating a hard-coded switch statement.
....I'd like to say something like:
foreach ($xml->xpath("/template/div") as $adiv)
$myfunc = $adiv[@src];
$this->divs[$cnt] .= $myfunc;
.....or maybe something like:
eval ("$this->divs[$cnt] .= $myfunc");
$this->divs[$cnt] .= '</div>';
...but of course none of the above works.
I don't want to have to remember to modify a switch
statement every time I add a new function to the class,
that might end up specified in the XML.
Re: How to call a class function from XML
You could parse the xml file with php xslt processor. The Xslt
Processor class has
a function called registerPHPFunction(). You can find it in the doc!
The you you
could do something like this
// this line calls the php function
Maybe this is a solution of your problem