Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Feb 2009
    Location
    Seattle, WA
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm looking for a simple explanation of how to take my forecast.asp page and access the National Weather Services xml forecast feed... I can't find an easy explanation anywhere that doesn't involve multiple files... Seems like this shouldn't be too difficult, but I can't get the hang of it... Does anyone have any experience doing this or better luck googling this than me?
    Thanks in advance,
    Dan

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    [quote name='cgschlangen' post='783731' date='08-Jul-2009 23:17']I'm looking for a simple explanation of how to take my forecast.asp page and access the National Weather Services xml forecast feed... I can't find an easy explanation anywhere that doesn't involve multiple files... Seems like this shouldn't be too difficult, but I can't get the hang of it...[/quote]
    Do you want to "manually" process the XML file by reading it in code, or do you want to use XSLT to automatically transform it? (Asking these questions does not indicate that I can answer them, but simply that there is a lot of information on these two different things.)

  3. #3
    New Lounger
    Join Date
    Dec 2009
    Location
    Iowa
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can use something like this:

    Code:
    <%
    'Create xml dom and set sync to false so it will display before fully loaded
    'Set url of xml file after load
    
    Set objXML = Server.CreateObject("Microsoft.XMLDOM") 
    objXML.async = False
    objXML.SetProperty "ServerHTTPRequest", True
    objXML.Load ("http://www.xxxxxxxxx.xml") 'This can also be an asp file
    
    'Call document elements of xml file
    
    Set objRoot = objXML.documentElement
    
    'Call node items by tag name
    
    Set objItems = objRoot.getElementsByTagName("item")
    
    'Loop through items inside the item tag and assign to a variable
    
    For Each objItem in objItems
     
         Hdesc= objItem.selectSingleNode("description").Text 
         Htitle= objItem.selectSingleNode("title").Text 
         HLink= objItem.selectSingleNode("link").Text 
         Hwriter= objItem.selectSingleNode("source").Text
    
     Next
     
    'If necessary Call node items by a different tag name
     
    Set objX = objRoot.getElementsByTagName("image")
    
     
    'Loop through items inside the image tag and assign to a variable
     
     For Each x in objX
      
         Ttitle= x.selectSingleNode("title").Text 
         TLink= x.selectSingleNode("link").Text 
    
     Next
     
    
     
     'Write out values from variables create links etc 
    'This next bit is a very specific layout
    Response.Write "<div id=""lhm"" style=""width: 210px; background-image: url('images/xxxxxx.jpg'); background-repeat: repeat-x; border: 1px solid #C0C0C0; padding: 5px; font-size: 10pt;"">"
     
          Response.Write "" & Ttitle & ""
    
          Response.Write "" & Htitle & "Link"
    			
    			Response.Write FromHtml(Hdesc) & ""
    			
    			Response.Write "" & Hwriter & ""
    Response.Write "</div>"			
    			
    'Clean up objects just to be thorough	
    	
    Set objXML= Nothing			
    Set objRoot= Nothing
    Set objItems= Nothing	
    Set objX= Nothing		
    
    %>
    Hope this helps

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •