Jump to content

Asking for suggestions on how to work with XML files in PHP


ShotokanTuning

Recommended Posts

I've a couple directories filled with thousands of xml files.

 

I'm expected to generate, menu's with html links from each directory. I was thinking of using scandir() for that.

 

Also all these xml files should be reachable with their filename in the url.

 

For example in the article directory the xml file named news.xml should be reachable like this:

http://www.website.com/article/news.php

2nd example in the articles directory the xml file named helpwithjeans.xml should be reachable like this:

http://www.website.com/article/helpwithjeans.php?l=0

3rd example in the products directory the xml file named bluray.xml should be reachable like this:

http://www.website.com/product/bluray.php?l=1

 

How to read what url is typed and process it by going to the right xml file? After that the xml still needs to be converted to one of several specific html formats.

 

Something like using the parameter "l" see in above examples (2nd and 3rd) to know which layout is desired and which xml elements to grab.

 

How can this be handled? And if there is multiple options, what do you suggest is a good way to handle this.

 

Thanks for pointing me in the right direction!

 

I was thinking XSLT might be the way to convert the xml to html but I don't know how to use the "l" parameter from the url (if I'm heading int hat direction) in the XSLT and that would really be needed.

 

I'm really open to any input. Everything may help. Thanks a lot.

Link to comment
Share on other sites

In the XSLT world, you would expect a variable and apply it in your template. If you do not know a lot about XSLT I do not consider going that route, as it is fairly complex.

 

Sounds like you have quite the task on your hands. Good luck.

Link to comment
Share on other sites

Hi keeB,

 

Thanks a lot for the reply.

 

I've worked with XSLT before, just never used php together with xslt.

 

How to expect a variable and apply it in the template?

 

For example, I know of <xsl:param name="parameter"/> but I don't know how to use this with php. How to send that param to the xslt?

 

 

My biggest question is how to have the user type the url, catch that url with a php file/code and have it build a html page from the hidden xml file in the url.

 

With other words if I have for example the url "http://www.website.com/article/news.php" I want to catch that url (and every other url with the pattern http://www.website.com/article/*.php) with some php code. That php code needs to be able to grab the xml file, in this case in the directory article take the file with the name "news.xml" and convert it to a html page.

 

 

Thank you kindly,

ST

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.