MartyConnelly
martyconnelly at shaw.ca
Sun Feb 13 14:12:48 CST 2005
Here is a cute little demo of one type of xml use. It reads an RSS xml
news feed site from BBC technology daily news.
It transforms the returned xml news feed into an html file or string via
XSLT and displays in an IE window.
So you can click through to the news feed links.
This will work for Access 97 with no references assuming at least IE 5.1
loaded which has an early version XML parser.
You may have to change to use Msxml2.DOMDocument rather than
Msxml.DOMDOCUMENT
if you have an odd install of a later version of MS XML parser.
I have kept this as simple as possible no error checks, the xsl
transform file is found on one
my test websites, but you could download to a local disk file instead of
using the net access.
The xsl file is fairly generic. RSS feeds are simple xml files. But you
may want to modify xsl to display
dates and times.
I know there a lots of freebie RSS viewers out there but this shows what
goes on under the covers.
And how basic it really is.
Oh and the IE window method might be useful if you want to display large
amounts of continuous text.
You could also use this method to save url news feed links in a daily
searchable access table.
RSS What is it?
(Really Simple Syndication) A format for notifying new content at a
website; the initials originally stood for Rich Site Summary. RSS
defines rules for listing information about new content added to a
website, such as the title, link and a short description (or in some
cases the full body of the content), which the site publishes as an XML
file at a specific URL -- in effect, a web service. This file, often
called a newsfeed, can then be read and combined with feeds from other
sites by news aggregators, which display the consolidated information
either on a user's desktop or on a website. RSS is widely used both by
news sites and by weblogs. There are four versions in widespread use:
0.91, developed by Netscape; 0.92, a modification popularized by
Userland Software; 1.0, a variation based on RDF (Resource Description
Framework); and 2.0, formalized in September 2002 by Userland's Dave Winer.
Sub BBCRSSFeed()
Dim srcTree As Object
Dim xsltTree As Object
Dim strHTML As String
Set srcTree = CreateObject("Msxml.DOMDocument")
srcTree.async = False
srcTree.Load
("http://news.bbc.co.uk/rss/newsonline_uk_edition/technology/rss091.xml")
Set xsltTree = CreateObject("Msxml.DOMDOCUMENT")
xsltTree.async = False
'this xsl transform file can also be loaded via a local disk file
xsltTree.Load ("http://www5.brinkster.com/mconnelly/newsfeed.xsl")
strHTML = srcTree.transformNode(xsltTree)
'Debug.Print strHTML
' Display transformed xml rss news feed in html via IE 6.0 window
testIE (strHTML)
End Sub
Sub testIE(strpassHTML As String)
'------------------
' Display html string in IE window
Dim objExplorer As Object
Dim objDocument As Object
Dim strComputer As String
Dim strReturn As String
Set objExplorer = CreateObject("InternetExplorer.Application")
objExplorer.Navigate "about:blank"
objExplorer.Toolbar = 0
objExplorer.StatusBar = 0
objExplorer.Width = 800
objExplorer.Height = 570
objExplorer.Left = 0
objExplorer.Top = 0
objExplorer.Visible = 1
'dont't need this to navigate to file or http site
'just drop html string in document object
'objExplorer.Navigate "file://c:\temp\test.html"
'objExplorer.Navigate "http://checkip.dyndns.org/"
Do While (objExplorer.Busy)
Loop
Dim webtx As String
Dim strHTML As String
Set objDocument = objExplorer.Document
objDocument.Open
objDocument.Writeln "<html><head><title>My BBC Technology RSS
Feed</title></head>"
objDocument.Writeln "<body bgcolor='white'>"
objDocument.Writeln "<table width='100%'>"
objDocument.Writeln "<tr>"
objDocument.Writeln "<td width='20%'><b>BBC Feed</b></td>"
objDocument.Writeln "</tr>"
objDocument.Writeln "</table>"
objDocument.Writeln strpassHTML
objDocument.Writeln "</body></html>"
'objDocument.Write()
objDocument.Close
'MsgBox "finished"
Set objExplorer = Nothing
Set objDocument = Nothing
End Sub
--
Marty Connelly
Victoria, B.C.
Canada