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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RSS feed formatting 1

Status
Not open for further replies.

ralphonzo

Programmer
Apr 9, 2003
228
0
0
GB
Hi, I've been going bonkers trying to format the data from an RSS feed. The problem I'm having is with the image/text wrap. Is it possible to disable that?

I've been trying to sort it out server side with VBScript (it's on an ASP not PHP page), but I got some advice to ask you CSS types. Here's the code I'm currently using:

Code:
dim xmlDom, nodeCol, oNode, oChildNode
            set xmlDom = Server.CreateObject("MSXML2.Domdocument.4.0")
            
            call xmlDom.setProperty("ServerHTTPRequest", true)
            xmlDom.async = false
            call xmlDom.load("[URL unfurl="true"]http://www.postconflictheritage.com/home/pch_blog/rss.xml")[/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("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
I'm more than happy to use any language (that works - even PHP if there's no other option, but I'm sure there must be!!) in order to perform this task.
 
you should be able to apply an XSTL template to the xml and be done with it. here is an introduction on the topic. once you have the xsl template asp can merge the two.


Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
I'm sorry, I just don't get it. Most of the advice seems to assume that you can edit the XML file before it reaches its destination. I'm receiving the RSS feed from a third party. Does an XML file need creating on the fly somewhere? Am I missing something fundamental here?
 
you are not editing the xml file, you are defining layout for the xml via xsl. the xml is coming from the remote location. the xsl is defined by you. A file within your website. when you get the xml you apply the xsl to the xml and write the result to the response stream.

I'm not familiar with asp, but asp.net would look something like this
Code:
var rss = new XPathDocument("[URL unfurl="true"]http://www.domain.com/path/to/rss")[/URL] ;
var transformer = new XslTransform() ;
transformer.Load("path to xsl file (a file you define)") ;
transformer.Transform(rss, null, Response.Output);

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Thanks for the help. It works, and pretty much as I had it, but there's still the issue of the embedded images. They seem to employ some sort of pointer to an 'enclosure' attribute that has no closing tag. Has anyone come across these? Is there a way of isolating this data?
 
The problem I'm having is with the image/text wrap.
there's still the issue of the embedded images
Could you explain what the problem is that you're having?

You're using a mechanism to transform an XML feed into HTML. That HTML is not rendering quite how you would like it. That's probably something we can fix on this forum.

However, what we need is the HTML that you generate - do a "view source" when you view the end result in a browser. Posting the ASP you use to generate the page is of limited use. You also need to tell us just what effect you're trying to achieve.

That way you might get some help.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
That sounds good.

This HTML:

Code:
<p>
<span class='titler'>new book series, manuscripts wanted</span>
  &raquo; Wed, 5 Aug 2009 09:48:50 +0100<br />
  <a href="[URL unfurl="true"]http://www.postconflictheritage.com/home/pch_blog/Entries/2009/8/5_new_book_series_files/IMG_8425.jpg"><img[/URL] src="[URL unfurl="true"]http://www.postconflictheritage.com/home/pch_blog/Media/IMG_8425.jpg"[/URL] style="float:left; padding-right:10px; padding-bottom:10px; width:712px; height:473px;"/></a><br/>IB Taurus has launched what looks to be a very promising book series on post-conflict reconstruction and development. <br/><br/>as the text below indicates, they are on the look out for new manuscripts.<br/><br/><br/>International Library of  <br/><br/>POSTWAR RECONSTRUCTION AND DEVELOPMENT<br/><br/><br/>INVITATION TO PUBLISH <br/><br/>The International Library of Postwar Reconstruction and Development was established to provide an overview and critique of post-conflict transitions. It aims to make available a comprehensive series of volumes that will guide and inform both theory and practice. We hope that books in the series will find an audience among professionals in reconstruction and development as well as among academics and students of international relations, development studies, postwar recovery, security studies and economics. <br/><br/>Recently published and forthcoming volumes include: <br/><br/>?? Disaster Management and Civil Society: Earthquake Relief in Japan, Turkey and India (2005) <br/>?? Post-war Recovery: Disarmament, Demobilization and Reintegration (2008) <br/>?? Violence and Post-war Reconstruction: Managing Insecurity in the Aftermath of Peace Accords (2009) <br/>?? Policy Transfer in Post-war Reconstruction (2009) <br/><br/>We welcome interest from both professionals and academics in postwar reconstruction and related areas. Key topics of interest are: <br/><br/>?? Researching in Conflict <br/>?? Ethnicity and Reconstruction <br/>?? Aid Financing for Post-Conflict Reconstruction <br/>?? Post-Conflict Public Administration Reform and Civil Service Strengthening <br/>?? Anti-Corruption and Integrity <br/>?? Civil-Military Cooperation <br/>?? Peacekeeping and Transitional Administration <br/>?? Security and Justice Sector Reform <br/>?? Transitional Justice and Human Rights <br/><br/>Preference will be given to thematic rather than country- or context-specific pieces unless a strong argument can be made for the latter. Interested authors are invited to submit proposals for the series. A proposal should include a one-page overview of the book and a 200-word abstract for each envisioned chapter. In the case of edited volumes, please name the intended author of each chapter; only authors who have expressed interest in contributing to the volume should be included. Also provide an anticipated date of delivery and the expected length of the manuscript, and please indicate the status of the project, i.e. whether it is at outline stage or a full manuscript is available. Applications should be accompanied by the CV (no more than 10 pages) of the proposed author or editor; in the case of edited volumes, please provide short (4- to 6-sentence) profiles of the contributors, including current employment/affiliation and recent publications. <br/><br/>Please send proposals to the Series Editor, Professor Sultan Barakat of the University of York’s Post-war Reconstruction and Development Unit (PRDU), at <a href="Entries/2009/8/5_new_book_series_files/mailto%253Aszb1%2540york.ac.uk">szb1@york.ac.uk</a>, copying all messages to <a href="Entries/2009/8/5_new_book_series_files/mailto%253Asc23%2540york.ac.uk">sc23@york.ac.uk</a>. <br/>Proposals may also be sent to David Stonestreet, Senior Editor at I.B. Tauris, at <a href="Entries/2009/8/5_new_book_series_files/mailto%253Adstonestreet%2540ibtauris.com">dstonestreet@ibtauris.com</a> or at 6 Salem Road, London W2 4BU, United Kingdom. Confirmation will be sent upon receipt of applications. Once proposals have been reviewed internally and externally, applicants will receive a response. We aim to provide responses within six weeks of receipt. <br/><br/>For additional information on books within this series, please visit <a href="[URL unfurl="true"]http://www.ibtauris.com/ILPRD">www.ibtauris.com/ILPRD</a>.<br[/URL] />

  <br />
  <a href="[URL unfurl="true"]http://www.postconflictheritage.com/home/pch_blog/Entries/2009/8/5_new_book_series.html"[/URL] target="_blank">    more...
  </a>
</p>

renders from the following XML feed:

Code:
<item>
      <title>new book series, manuscripts wanted</title>

      <link>[URL unfurl="true"]http://www.postconflictheritage.com/home/pch_blog/Entries/2009/8/5_new_book_series.html</link>[/URL]
      <guid isPermaLink="false">422a7bae-cfee-4e8b-a8bd-f0b8fbc70e98</guid>
      <pubDate>Wed, 5 Aug 2009 09:48:50 +0100</pubDate>
      <description>&lt;a href=&quot;[URL unfurl="true"]http://www.postconflictheritage.com/home/pch_blog/Entries/2009/8/5_new_book_series_files/IMG_8425.jpg&quot;&gt;&lt;img[/URL] src=&quot;[URL unfurl="true"]http://www.postconflictheritage.com/home/pch_blog/Media/IMG_8425.jpg&quot;[/URL] style=&quot;float:left; padding-right:10px; padding-bottom:10px; width:712px; height:473px;&quot;/&gt;&lt;/a&gt;&lt;br/&gt;IB Taurus has launched what looks to be a very promising book series on post-conflict reconstruction and development. &lt;br/&gt;&lt;br/&gt;as the text below indicates, they are on the look out for new manuscripts.&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;International Library of  &lt;br/&gt;&lt;br/&gt;POSTWAR RECONSTRUCTION AND DEVELOPMENT&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;INVITATION TO PUBLISH &lt;br/&gt;&lt;br/&gt;The International Library of Postwar Reconstruction and Development was established to provide an overview and critique of post-conflict transitions. It aims to make available a comprehensive series of volumes that will guide and inform both theory and practice. We hope that books in the series will find an audience among professionals in reconstruction and development as well as among academics and students of international relations, development studies, postwar recovery, security studies and economics. &lt;br/&gt;&lt;br/&gt;Recently published and forthcoming volumes include: &lt;br/&gt;&lt;br/&gt;?? Disaster Management and Civil Society: Earthquake Relief in Japan, Turkey and India (2005) &lt;br/&gt;?? Post-war Recovery: Disarmament, Demobilization and Reintegration (2008) &lt;br/&gt;?? Violence and Post-war Reconstruction: Managing Insecurity in the Aftermath of Peace Accords (2009) &lt;br/&gt;?? Policy Transfer in Post-war Reconstruction (2009) &lt;br/&gt;&lt;br/&gt;We welcome interest from both professionals and academics in postwar reconstruction and related areas. Key topics of interest are: &lt;br/&gt;&lt;br/&gt;?? Researching in Conflict &lt;br/&gt;?? Ethnicity and Reconstruction &lt;br/&gt;?? Aid Financing for Post-Conflict Reconstruction &lt;br/&gt;?? Post-Conflict Public Administration Reform and Civil Service Strengthening &lt;br/&gt;?? Anti-Corruption and Integrity &lt;br/&gt;?? Civil-Military Cooperation &lt;br/&gt;?? Peacekeeping and Transitional Administration &lt;br/&gt;?? Security and Justice Sector Reform &lt;br/&gt;?? Transitional Justice and Human Rights &lt;br/&gt;&lt;br/&gt;Preference will be given to thematic rather than country- or context-specific pieces unless a strong argument can be made for the latter. Interested authors are invited to submit proposals for the series. A proposal should include a one-page overview of the book and a 200-word abstract for each envisioned chapter. In the case of edited volumes, please name the intended author of each chapter; only authors who have expressed interest in contributing to the volume should be included. Also provide an anticipated date of delivery and the expected length of the manuscript, and please indicate the status of the project, i.e. whether it is at outline stage or a full manuscript is available. Applications should be accompanied by the CV (no more than 10 pages) of the proposed author or editor; in the case of edited volumes, please provide short (4- to 6-sentence) profiles of the contributors, including current employment/affiliation and recent publications. &lt;br/&gt;&lt;br/&gt;Please send proposals to the Series Editor, Professor Sultan Barakat of the University of York’s Post-war Reconstruction and Development Unit (PRDU), at &lt;a href=&quot;Entries/2009/8/5_new_book_series_files/mailto%253Aszb1%2540york.ac.uk&quot;&gt;szb1@york.ac.uk&lt;/a&gt;, copying all messages to &lt;a href=&quot;Entries/2009/8/5_new_book_series_files/mailto%253Asc23%2540york.ac.uk&quot;&gt;sc23@york.ac.uk&lt;/a&gt;. &lt;br/&gt;Proposals may also be sent to David Stonestreet, Senior Editor at I.B. Tauris, at &lt;a href=&quot;Entries/2009/8/5_new_book_series_files/mailto%253Adstonestreet%2540ibtauris.com&quot;&gt;dstonestreet@ibtauris.com&lt;/a&gt; or at 6 Salem Road, London W2 4BU, United Kingdom. Confirmation will be sent upon receipt of applications. Once proposals have been reviewed internally and externally, applicants will receive a response. We aim to provide responses within six weeks of receipt. &lt;br/&gt;&lt;br/&gt;For additional information on books within this series, please visit &lt;a href=&quot;[URL unfurl="true"]http://www.ibtauris.com/ILPRD&quot;&gt;www.ibtauris.com/ILPRD&lt;/a&gt;.[/URL] </description>

      <enclosure url="[URL unfurl="true"]http://www.postconflictheritage.com/home/pch_blog/Entries/2009/8/5_new_book_series_files/IMG_8425.jpg"[/URL] length="66398" type="image/jpeg"/>
    </item>

The problem is the 'enclosure url' image. I just can't seem to target it for formatting!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top