#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    2
    Rep Power
    0

    Yahoo RSS News Feed Help!


    I was wondering if anyone could help me with this?

    I want to use yahoos news feeds on my site.
    When I put a direct URL link to an XML file on my computers CFMX Server It works.

    Example:
    <CFHTTP URL="http://localhost:8500/news/health.xml" METHOD="get" RESOLVEURL="no"/>

    Now when I direct the URL link to Yahoos feed it comes up with an error saying that a Document root element is missing!

    Can anyone help me with this.

    Here Is my code:

    <CFHTTP URL="http://rss.news.yahoo.com/rss/health" METHOD="get" RESOLVEURL="no"/>

    <CFSCRIPT>
    objRSS = trim(cfhttp.filecontent);
    objRSS = XMLParse(objRSS);
    </CFSCRIPT>

    <CFSET XMLRoot = objRSS.XmlRoot >
    <CFSET News_Length = arraylen(XMLRoot.channel.item) >

    <CFLOOP index="i" from="1" to="#News_Length#" >
    <CFSET item_title = XMLRoot.channel.item.title.xmltext >
    <CFSET item_link = XMLRoot.channel.item.link.xmltext >
    <CFSET item_pubDate = XMLRoot.channel.item.pubDate.xmltext >
    <CFSET item_description = XMLRoot.channel.item.description.xmltext >
    <CFOUTPUT>
    <STRONG>#item_title#</STRONG><br/>
    #item_pubDate#<br/>
    <a href="#item_link#">#item_description#</a><br/>
    <br/>
    </CFOUTPUT>
    </CFLOOP>



    Thanks
    area215
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,264
    Rep Power
    968
    You're just not using the correct XML root element. Try using the <rss> or the <channel> element. Remember that XML objects are referenced in array and structure syntax like someelement[1].subelement[1].

IMN logo majestic logo threadwatch logo seochat tools logo