Forum Moderators: coopster

Message Too Old, No Replies

Php tied with xml a bit of html logic.

         

tftd

8:42 pm on Sep 10, 2008 (gmt 0)

10+ Year Member



Hey everybody,

I'm trying to do something that's already done by IPB.
They call it "html logic".
I'll try to explain how it works...
We have a xml file with data inside.
Here is a small example


<html>
<![CDATA[

<span><if="$_COOKIE['user']">Hello $_COOKIE['user']</if></span>

]]>
</html>

What their xml parser will do after you re-cache the skin is to save some parts of the xml file (containing html) into php files. The <if>$data</if>/<else>$something</else> tags will be replaced with if($data){echo $something} else{echo $nothing}

I want to understand that method of replacing those tags because I'll be needing it. Could somebody give me a hand by giving me some advices/tutorials or pieces of working code ?

Thanks in advance,
tftd

eelixduppy

5:02 am on Sep 15, 2008 (gmt 0)



For something like this you are probably looking for an event-based parser for PHP, so SimpleXML [php.net] is probably someone's first suggestion, it's probably not the best way to get this done. I'd take a look at using something like Expat [google.com] for this project. Once you're able to parse the XML, it shouldn't be too difficult to write PHP files using fwrite [php.net], etc... Take a look and see where you can get.

Good luck.