Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting an XML rss feed 2

Status
Not open for further replies.

ralphonzo

Programmer
Apr 9, 2003
228
GB
Does anyone have an idea how to interogate the 'description' tag of the rss feed from TechCrunch? I can't identify the image within the content in order to format it, and no matter what I try the text always pops up to its right at the bottom. I'm rubbish with XML!

There's a live model of what's happening at:
and here's my ASP/VBScript code:

Code:
<!-- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -->
<?xml version="1.0" encoding="utf-8"?>

<html>
<head>
<title>Clockwork Gallery</title>
<meta http-equiv="content-language" content="EN">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<table width="100" border="0" cellpadding="0" cellspacing="10">
  <tr>
    <td><%
	dim xmlDom, nodeCol, oNode, oChildNode
	set xmlDom = Server.CreateObject("Microsoft.XMLDOM")
	'set xmlDom = Server.CreateObject("Msxml2.FreeThreadedDomDocument.4.0")  
	
	call xmlDom.setProperty("ServerHTTPRequest", true)
	xmlDom.async = false
	'call xmlDom.load("[URL unfurl="true"]http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/technology/rss.xml")[/URL]
	call xmlDom.load("[URL unfurl="true"]http://feeds.feedburner.com/Techcrunch")[/URL]
	
	
	if not xmlDom.documentElement is nothing then
	  set nodeCol = xmlDom.documentElement.selectNodes("channel/item")
	  for each oNode in nodeCol
		Response.Write("<p>"& vbCrLf)
		'set oChildNode=oNode.selectSingleNode("*[local-name()='content']/@url")
		'if not oChildNode is nothing then
			'Response.Write "<img src=""" & oChildNode.NodeValue & """ alt=""" & ochildnode.NodeValue & """ />XYZ<br />" & vbcrlf
		'end if
		set oChildNode = oNode.selectSingleNode("title")
		if not oChildNode is nothing then
		  Response.Write("  <h3>" & oChildNode.text & "</h3>" & vbCrLf)
		end if
		'set oChildNode = oNode.selectSingleNode("pubDate")
		'if not oChildNode is nothing then
		 ' Response.Write("  &raquo; " & oChildNode.text & "<br />" & vbCrLf)
		'end if
		set oChildNode = oNode.selectSingleNode("description")
		if not oChildNode is nothing then
		  Response.Write("  " & oChildNode.text & "<br />" & vbCrLf)
		end if
		set oChildNode = oNode.selectSingleNode("link")
		if not oChildNode is nothing then
		  Response.Write("  <br />" & vbCrLf)
		  Response.Write("  <a href=""" & oChildNode.text & """ target=""_blank"">")
		  Response.Write("    more..." & vbCrLf)
		  Response.Write("  </a>" & vbCrLf)
		end if
		Response.Write("</p>" & vbCrLf)
	  next
	else
	  Response.Write("<p>" & vbCrLf)
	  Response.Write("  Sorry, no news today!" & vbCrLf)
	  Response.Write("</p>" & vbCrLf)
	end if %></td>
  </tr>
</table>
</body>
</html>
 
It's not the image that's the problem, it's the text. When I try to render response.write cnodes(j).NodeValue for the textual portion, it displays the text's originating http and not the actual content. How can this be corrected?
 
First let me amend the line in my last post to make good a typo. The corresponding line should be read like this.
[tt]
response.write "<div><img src='" & cnodes(j).NodeValue & "' alt='image (0[highlight],"[/highlight] & j & ")' /></div>"
[/tt]
As to the "text", what you meant is no longer cnodes(j).NodeValue. cnodes(j) is just the attribute src and sure you cannot do that for the purpose.

To get the text of the original "description": the meaning is doubly twisted. It is the xml-parsed text's text content. You do it like this (once, outside of the cnodes loop):
[tt]
response.write "<div>" & xmlDom.documentElement.text & "</div>"
[/tt]
At this juncture, I have to say you have now a concrete thing to work with and its time to go back to the foundation of xml to acquire, not only the vocab, but the elements for proper deduction and reasoning with it.
 
That's absolutely spot on. We got there in the end, thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top