ASP Classic parse of a RSS news feed not working

Thanks in advance for any help.

I have an ASP classic basic script which reads an xml file (http://gsmworld.com/rss/press_releases_2009.xml) and converts it to a JSON string.

It works fine on several feeds, apart from the above mentioned one, which gives me the error:

Microsoft VBScript runtime  error '800a01a8'

Object required: 'oDOM.documentElement'

/get/feed/Default.asp, line 21

Line 21 and it's surround code is below.

So anyone got any idea, why this XML feed would have an issue? Or, does anyone know of a good standard for parsing XML using ASP?

vConfig is just the body of the XML feed, pulled in via an http request.
Set oDOM = server.CreateObject("MSXML2.DOMDocument")
		oDOM.LoadXML(vConfig)
		
 
Line 21 >	Set oRoot = oDOM.documentElement.selectSingleNode("/rss")
			on error resume next
			nVersion 		= oRoot.selectSingleNode("@version").text
			if nVersion = "2.0" then
				vTitle			= oDOM.documentElement.selectSingleNode("/rss/channel/title").text
				vLink			= oDOM.documentElement.selectSingleNode("/rss/channel/link").text
				vDescription	= oDOM.documentElement.selectSingleNode("/rss/channel/description").text
				vLanguage		= oDOM.documentElement.selectSingleNode("/rss/channel/language").text

Open in new window

jhaley-telecomtvAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

giuseppepiCommented:
Try out this one
<%
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.setProperty "ServerHTTPRequest", true 
 
objXML.async = False
 
'Carica il file XML o il feed rss in formato xml
strFile= "http://gsmworld.com/rss/press_releases_2009.xml"
objXML.Load (strFile)
 
Set AllItems = objXML.selectNodes("//channel")
 
For I = 0 to (AllItems.Length - 1)
  Set Post = AllItems(I).selectNodes("item")
  For J = 0 to (Post.Length-1)
      Set title = Post(J).selectNodes("title")
      Set description = Post(J).selectNodes("description")
      Set link = Post(J).selectNodes("link")
      Set lang = Post(J).selectNodes("language")
 
%>
<a href="<%=link(0).text%>" target="_blank"><%=title(0).text%></a><br>
<%=description(0).text%><br><%= language(0).text%><br><br>
<%
  Next
    Set title = Nothing
    Set description = Nothing
    Set link = Nothing
    Set Post = Nothing
Next
%>

Open in new window

0
giuseppepiCommented:
Try out this one
<%
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.setProperty "ServerHTTPRequest", true 
 
objXML.async = False
 
'Carica il file XML o il feed rss in formato xml
strFile= "http://gsmworld.com/rss/press_releases_2009.xml"
objXML.Load (strFile)
 
Set AllItems = objXML.selectNodes("//channel")
 
For I = 0 to (AllItems.Length - 1)
  Set Post = AllItems(I).selectNodes("item")
  For J = 0 to (Post.Length-1)
      Set title = Post(J).selectNodes("title")
      Set description = Post(J).selectNodes("description")
      Set link = Post(J).selectNodes("link")
      Set language = Post(J).selectNodes("language")
 
%>
<a href="<%=link(0).text%>" target="_blank"><%=title(0).text%></a><br>
<%=description(0).text%><br><%=language(0).text%><br><br>
<%
  Next
    Set title = Nothing
    Set description = Nothing
    Set link = Nothing
    Set Post = Nothing
    Set language = Nothing
Next
%>

Open in new window

0
jhaley-telecomtvAuthor Commented:
That doesn't work, I get a Object Required message when trying to use that script. It's because some of the data, like description isn't available on all records!
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

jhaley-telecomtvAuthor Commented:
This is the full current code:
Dim vConfig : Dim vResponse
		vConfig = GetFile(request("f"))
		
		'prep json response
		vResponse =  "{""news"":"
		
		Set oRE= new RegExp : oRE.Pattern="[\f\n\r\t\v]| {2,}" : oRE.IgnoreCase = true : oRE.Global = true
		vConfig=oRE.Replace(vConfig,"")
		
		' Read config file
		Set oDOM = server.CreateObject("MSXML2.DOMDocument")
		oDOM.LoadXML(vConfig)
		
		' Set Root and get page properties
		Set oRoot = oDOM.documentElement.selectSingleNode("/rss")
			on error resume next
			nVersion 		= oRoot.selectSingleNode("@version").text
			if nVersion = "2.0" then
				vTitle			= oDOM.documentElement.selectSingleNode("/rss/channel/title").text
				vLink			= oDOM.documentElement.selectSingleNode("/rss/channel/link").text
				vDescription	= oDOM.documentElement.selectSingleNode("/rss/channel/description").text
				vLanguage		= oDOM.documentElement.selectSingleNode("/rss/channel/language").text
				
				'output settings
				vResponse=vResponse & "{""state"":""pass"",""title"":""" & vTitle & """,""link"":""" & vLink & """,""description"":""" & vDescription & """,""language"":""" & vLanguage & ""","
				
				'ouput items
				vResponse=vResponse & """items"":["
				
				Set oItems = oRoot.selectNodes("//item")
					if oItems.length > 0 then
						for each oItem in oItems
							vResponse=vResponse & "{""title"":""" & oItem.selectSingleNode("title").text & ""","
							vResponse=vResponse & """description"":""" & oItem.selectSingleNode("description").text & ""","
							vResponse=vResponse & """link"":""" & oItem.selectSingleNode("link").text & ""","
							vResponse=vResponse & """guid"":""" & oItem.selectSingleNode("guid").text & ""","
							vPubDate = oItem.selectSingleNode("pubDate").text
							if vPubDate = "" then
								vResponse=vResponse & """pubDate"":""""},"
							else
								vResponse=vResponse & """pubDate"":""" & vPubDate & """},"
							end if
						next
					end if
				vResponse=left(vResponse,len(vResponse)-1)
				vResponse=vResponse & "]}"
			else
				vResponse=vResponse & "{""state"":""fail""}"
			end if
		
		vResponse = vResponse & "}"
		
		' Clean up
		vResponse=replace(vResponse,"","&quot;")
		vResponse=replace(vResponse,"","&quot;")
		vResponse=replace(vResponse,"","'")
		vResponse=replace(vResponse,"®","&reg;")
		vResponse=replace(vResponse,""","&#8482;")
		
		' Output 
		response.write vResponse

Open in new window

0
giuseppepiCommented:
Yeah, true. I did not try before!
But the error is in language! I got it working.
<%
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.setProperty "ServerHTTPRequest", true 
 
objXML.async = False
 
'Carica il file XML o il feed rss in formato xml
strFile= "http://gsmworld.com/rss/press_releases_2009.xml"
objXML.Load (strFile)
 
Set AllItems = objXML.selectNodes("//channel")
 
For I = 0 to (AllItems.Length - 1)
  Set Post = AllItems(I).selectNodes("item")
  For J = 0 to (Post.Length-1)
      Set title = Post(J).selectNodes("title")
      Set description = Post(J).selectNodes("description")
      Set link = Post(J).selectNodes("link")
 
 
%>
<a href="<%=link(0).text%>" target="_blank"><%=title(0).text%></a><br>
<%=description(0).text%><br><br>
<%
  Next
    Set title = Nothing
    Set description = Nothing
    Set link = Nothing
    Set Post = Nothing
Next
%>

Open in new window

0
jhaley-telecomtvAuthor Commented:
Thanks for the response. I found another solution, using Yahoo Pipes to generate the JSON  for me.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.