Jump to content

[SOLVED] How to to process an XML file, HTML-ize lines of data?


slarkler

Recommended Posts

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.