Parsing WML into HTML, Part 2By Thomas Winningham
In Part 1 we looked at how to use ASPTear to grab the headlines from Slashdot in XML form. In this part we will look at the source to parse the WML version of Slashdot's article list. You'll notice a few things:
- My use of ASPTear instead of the XMLDOC.load to get the WML file.
- My use of random numbers which create a unique but harmless extraneous url -
slashdot.wml?random=23048- to overcome caching by ASPTear, and c) parsing of WML just like XML.
This produces an output like this:
Current Slashdot Articles:
Linux In A Box
HP Plans The Uber-Calculator
Transmeta Testing Mass Production
Windows ME - The End Of UMSDOS And BeOSfs Over Vfat?
File Packaging Formats - What To Do?
Sir Alec Guinness Dies
New Images Of Titan's Surface Released
HelixCode Releases Admin Tools
Sega Shutting Down Hundreds Of ROM Sites
Which is great for using a HTML to Email service like Grabpage
or Speedylink. Now, HTML is a markup language
just like XML and WML are. It's all just tags. I have found that most web browsers are rather forgiving, as are
HTML to Email services, so in the last block of code, we like each article to a file called
showarticle.asp, which simply displays the WML without any modification. Most web browsers seem
to display this with little problem, and both email services I mentioned do too. Here's the code for the
As you can see, we're basically getting the WML, and displaying it. The purpose for this, is that since we are circumventing WML as a reusable resource for raw data, we need to realize that most browsers upon seeing the .WML will try to save or otherwise not display it. It is essentially text, and we can grab it from the server for processing. An example output of this code is here:
Linux In A Box
Henrik pointed us to the Linux in a Box project, which is a bitchin' little project to create an inexpensive little Linux box: it boots a 2.0.36 kernel from a ramdisk, and it's pingable and Telenetable, as well as being usable as a Web server. Only for the brave of heart and willing to hack.
The Palm interface (http://slashdot.org/palm) to Slashdot goes further than the WML to also offer the top 10 comments from users, and honestly I've started using it as my Slashdot fix while on the road. It's reasonably current lately, and is of course a great read.
So, as you can see, WML is a valuable resource even though it is intended for wireless devices. The Internet's trend to XML has been somewhat encouraged by WML, and we should observe the data portability that WML can still offer, since it essentially is just XML data. Again, a good way to avoid ASPTear or ISP caching is to use random number generators to add extra url strings (that will be ignored by the remote scripts usually), and the Microsoft XMLHTTPREQUEST is currently broken for use in server side applications. Thanks for reading!
All trademarks and copyrights on this page are owned by their respective owners. Slashdot Comments are owned by the Poster. The Rest of the Slashdot content is ©1997-2000 Andover.Net.