First off, I'm new to php, soo..... (yes, I'm studying, but did not get to xml yet)
This is for an experiment I'm busy with re multilingual sites. I want to figure the best performing method, and then create a sample solution for all to share.
For this specific test, I want to store text in xml files like this:
in my code I want to be able to call a function to get the text like this:Code:<text id="lblHome"> <en>Home</en> <ja>家</ja> <zh>家庭</zh> <description>Link to the home page</description> </text> <text id="lblWork"> <en>Work</en> <ja>仕事</ja> <zh>工作</zh> <description>Link to the Work for Us Page</description> </text>
In an included file a function like this (pseudo code):Code:<h1><?php GetText('lblHome'); ?></h1>
What I would like to know is the best way to only read a value from an xml file quickly. From the code I looked at earlier, it seems one loop through the xml file...this does not sound right to me (but then, I had a quick look)Code:function GetText(value) { $lang = get the current language from session load xml file $text = get value of X node for given value parent node (X will be 'en', 'ja', 'zh') return $text; }




Reply With Quote