slarkler Posted December 14, 2007 Share Posted December 14, 2007 I am trying to write a script that will process lines of an XML file, turn parts into PHP variables and insert them into HTML. I basically have no idea what I am doing. The XML is very simple. Theres only one key/tag thing, with various data in each line. I am using wget to get the file from another server, so it ends up as a file on my server. The files go like... <entry username="sniddle" id="768" image="084" time="1161703947"/> <entry username="friddle" id="164" image="432" time="1158681420"/> <entry username="griddle" id="361" image="434" time="1158103243"/> I would like to insert the data into html. This is all I can figure out so far... Some_sort_of_loop_thing(something){ $time2=(date('g:i.s a, m \/ d',$time); print(User link <a href='http://zlerk.com/user=$id'> $name </a>, user image <img src='http://zlerk.com/images/$image'> time added $time2 ); } I can't figure out how to process a file line by line, and extract the different parts and turn them into PHP variables. If anybody can suggest how to do this, or what functions or realms of PHP might help, or even which part of the manual, I would be most appreciative! Quote Link to comment Share on other sites More sharing options...
slarkler Posted December 14, 2007 Author Share Posted December 14, 2007 I have some vague idea that I might be able to use this function http://www.phpfreaks.com/quickcode/Return-array-of-strings-based-on-surrounding-tags/325.php to make arrays from each type of data, and then make them into variables one by one. Or something. Quote Link to comment Share on other sites More sharing options...
slarkler Posted December 14, 2007 Author Share Posted December 14, 2007 Okay, that function didn't help. It's not even clear whether it works. Any ideas would be appreciated! Quote Link to comment Share on other sites More sharing options...
slarkler Posted December 14, 2007 Author Share Posted December 14, 2007 I'm getting the feeling 'explode' might help me, at least, with each line. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.