Posts tagged ‘XML’

Dynamically Assigning XSLT And XML Files Via PHP And Apache mod_rewrite

Recently asked on Yahoo! Answers:

How to work with XML files in PHP?
I’ve a couple directories filled with thousands of xml files.

Also all these xml files should be reachable with their filename (but have .php at the end instead of .xml) 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/helpwithj
3rd example in the products directory the xml file named “bluray.xml” should be reachable like this:
http://www.website.com/product/bluray.ph

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.

The most efficient way to accomplish this task is via a combination of Apache’s mod_rewrite module and PHP’s XSLTProcessor class.

By adding the two together, we can reduce the number of files needed to convert any number of these XML files to one PHP file.

Continue reading ‘Dynamically Assigning XSLT And XML Files Via PHP And Apache mod_rewrite’ »

An ASP.NET Subroutine To Locally Store The National Weather Service Current Observations XML Feeds

As promised in my last article, here’s some ASP.NET 2.0 / VB.NET code to locally store / cache the National Weather Service’s current observations XML feeds.

The first step in this process is to create a directory on your Web server that is writeable. The second is to determine how, and when, you’ll update your feeds. Then, we can write the code.

Continue reading ‘An ASP.NET Subroutine To Locally Store The National Weather Service Current Observations XML Feeds’ »

Using National Weather Service XML Feeds With ASP.NET, ADO.NET And XSL

In a previous article, I noted that I would provide ASP.NET code to consume the National Weather Service’s XML current observation feeds. Here it is.

In the case of PHP, I opted to create a class that would provide a simple array of values from the feed, as well as some predefined outputs for the feed (so far, just an HTML table; in a soon-to-be-released update, we’ll include DIV tags).

In the case of ASP.NET, I may yet build a custom control that creates an image with current weather. But ADO.NET — Microsoft’s classes for data manipulation — makes working directly with the XML feed, and using that data to bind to DataGrids and the like, very simple and direct.

That is, provided you can get the XML feed to work with the XMLDataSource control.

Continue reading ‘Using National Weather Service XML Feeds With ASP.NET, ADO.NET And XSL’ »

National Weather Service Current Observations PHP Script Project Has First Release

As previously promised, I’ve finally gotten around to producing a PHP script to help people with limited programming skills use the National Weather Service’s free current observations XML feeds.

The script — actually, a PHP 5 class — is available at http://nws-feeds-php.sourceforge.net/. Any questions, comments, support requests, etc. should be directed there.

Free Weather On Your Website Via The National Weather Service’s RSS Feeds

A lot of Web sites like to offer current weather observations, and there are several providers out there that will either give you a free, pre-sized box for that contains that information — provided you let them splash their logo all over it and link the image back to them, driving traffic away from your site — or charge you a premium for the information.

But the U.S. government provides this information for you, free of charge, via XML and RSS. That’s right: No matter where you are in the United States, with a little bit of programming, you can make your own current observations weather box, free of charge, and customize it to look exactly how you want it to look.

Continue reading ‘Free Weather On Your Website Via The National Weather Service’s RSS Feeds’ »