To read the article online, visit http://www.4GuysFromRolla.com/webtech/080900-1.shtml

Parsing WML into HTML

By Thomas Winningham


I picked up a Pocket Mail (http://www.pocketmail.com) portable email device, and have since been working on various projects to get things done while I'm out of town. I've become quite a Slashdot addict while I'm actually in the office, but have missed the stories while traveling. They have a very good Palm interface that works great, but at the time of writing this code, it was not getting updated often. I did find, however, that their WML interface, which includes the stories in text format, was working fine.

Slashdot also has a nice XML version (http://slashdot.org/slashdot.xml) that is just as easily parsed using the Microsoft XMLDOM in ASP, but only contains links to the stories, and no actual content besides the title of news articles. Here is a way to parse the XML code to display a list of stories and other information:

<%
'wait to send to browser until a complete output is created
response.buffer = true

Set XMLdoc = Server.CreateObject( "Microsoft.XMLDOM" )
XMLDoc.async = false 'wait until XML is loaded before continuing

'load it, if successful then
if xmldoc.load("http://slashdot.org/slashdot.xml") then
  'now that its loaded, lets drill down on what we have
  XSLString = "backslash/*"
  Set oNodeList = xmlDoc.selectNodes(XSLString)
  
  'now that its loaded, lets drill down on what we have
  For Each Item in oNodeList  
    'display the date/section/url for each article
    response.write item.childnodes.item(2).text & ":"
    response.write item.childnodes.item(7).text & ":"
   
    strurl = item.childnodes.item(1).text
    response.write "<a href=""" & strurl
    response.write """>"
    response.write item.childnodes.item(0).text
    response.write "</a>"
    response.write " by " & item.childnodes.item(3).text
    response.write "<br>" & vbcrlf
  Next
else
  'What to say if we couldn't get the XML
  response.write "Unsucessful loading of slashdot.xml<BR>"
end if

set xmldoc = nothing 'clean up
%>

For more information on XML be sure to visit the XML Article Index!

This produces an output like this with links to the articles:

2000-05-18 12:32:10:articles:Boo No More by emmett
2000-05-18 12:05:53:articles:Main Linux Distros Port To IBM's S/390 by HeUnique
2000-05-18 10:01:23:bsd:OpenBSD, Reductionist Design by nik
2000-05-18 05:39:21:articles:Alpha Release Of Red Hat's Itanium Distro by timothy
2000-05-18 03:00:12:science:Online Book About Nano/AI by Hemos
2000-05-18 02:21:55:articles:Government Gives Microsoft Offer Thumbs Down by Hemos
2000-05-17 23:59:47:articles:H.R. 3113: Spam Bounty Hunters Wanted by timothy
2000-05-17 21:06:02:articles:Court Rules For Connectix, Against Sony by Hemos
2000-05-17 19:52:31:articles:E3: Linux Still Waiting In The Wings by timothy
2000-05-17 16:40:13:articles:Dialectizer Shut Down by emmett

There's a couple of important things to note here. First off, Slashdot is a very busy site, and they recommend that you only use the slashdot.xml once every 30 minutes. Another issue is that the Microsoft XMLDOM is somewhat broken when it comes to use in ASP.

According to this article at http://support.microsoft.com/support/kb/articles/Q237/9/06.ASP, it is probably best to select another means of using outside HTTP data for use in your ASP programs. Currently I've been using ASPTear from Softwing. Version 1.0 is a free download, and version 1.2 is a commercial product. There are many good articles on ASPTear as well, such as: Grabbing Information from Other Web Servers.

Now that we've looked at how to parse the XML Slashdot feed, in Part 2 we'll look at how to obtain and parse the WML Slashdot feed! (For more information on WML and related technologies, be sure to visit the WML and HDML Article Index!)

  • Read Part 2


  • Article Information
    Article Title: Parsing WML into HTML
    Article Author: Thomas Winningham
    Published Date: Wednesday, August 09, 2000
    Article URL: http://www.4GuysFromRolla.com/webtech/080900-1.shtml


    Copyright 2017 QuinStreet Inc. All Rights Reserved.
    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers