comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Still more fun with XML
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Still more fun with XML [message #43231] Thu, 24 March 2005 08:44
Karl Schultz is currently offline  Karl Schultz
Messages: 341
Registered: October 1999
Senior Member
Since we're so deep into XML...

There's a really fun undocumented feature (that will be documented in the
next IDL) that allows the IDL XML DOM parser to read XML from a URL
instead of a local file.

Note the value of the FILENAME kwd in the code below.

This program reads an RSS feed from this weather web site. In particular,
it gets the weather for the Fort Collins - Loveland airport in Colorado.
Of course, you can change it to whatever airport you wish, as long as it
is reported on this site.

There is no DTD, but the RSS specifications are readily available and I
used those as a guide for this parser. I actually have a full RSS parser
in the works, but I need to finish it up.

Have fun,

Karl

++++++


pro weather

oDoc = OBJ_NEW('IDLffXMLDOMDocument', $
FILENAME='http://weather.gov/data/current_obs/KFNL.rss')

;; Get and print first title
oTitles = oDoc->GetElementsByTagName('title')
oTitle = oTitles->item(0)
oTextNodes = oTitle->getChildNodes()
print, (oTextNodes->item(0))->getNodeValue()
OBJ_DESTROY, oTitles

;; Loop through all the items, printing the titles and descriptions.
oItems = oDoc->GetElementsByTagName('item')
for i=0, oItems->getLength()-1 do begin

oItem = oItems->item(i)

oTitle = (oItem->GetElementsByTagName('title'))->item(0)
oTextNodes = oTitle->GetChildNodes()
for j=0, oTextNodes->getLength()-1 do $
print, (oTextNodes->item(j))->getNodeValue()
OBJ_DESTROY, oTitle

oDesc = (oItem->GetElementsByTagName('description'))->item(0)
oTextNodes = oDesc->GetChildNodes()
for j=0, oTextNodes->getLength()-1 do $
print, (oTextNodes->item(j))->getNodeValue()
OBJ_DESTROY, oDesc

endfor
print
OBJ_DESTROY, oDoc
end
[Message index]
 
Read Message
Previous Topic: Re: do I need this IF statement?
Next Topic: Re: GDL?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 13:55:07 PDT 2025

Total time taken to generate the page: 0.95946 seconds