rcbuchanan
asked on
Consolidating Multiple RSS Feeds!? - Problem with Multiple Layouts!?
Can u help.
I have multiple RSS feeds I need to parse ... but each RSS feed has a slightly different XML layout and I - frankly - have no idea how best to tackle the stripping / parsing into a consolidated / standard loop!?
these rss feeds, for example;
http://www.guardian.co.uk/rssfeed/0,,1,00.xml
- has this variable when XMLparsed using CF;
: rdf:RDF.item[i].title
http://michellemalkin.com/index.xml
- has this variable when XMLparsed using CF;
: rss.channel.item[i].title
Is there a way to call the 'item[i].title' part of each parsed XML variable ... as a standard call without having to hard code each RSS feed's unique XML structure individually? You see ... the RSS feed URLS are fed dynamically from my web site ... and hardcoding would be impossible.
Thanks!
R
I have multiple RSS feeds I need to parse ... but each RSS feed has a slightly different XML layout and I - frankly - have no idea how best to tackle the stripping / parsing into a consolidated / standard loop!?
these rss feeds, for example;
http://www.guardian.co.uk/rssfeed/0,,1,00.xml
- has this variable when XMLparsed using CF;
: rdf:RDF.item[i].title
http://michellemalkin.com/index.xml
- has this variable when XMLparsed using CF;
: rss.channel.item[i].title
Is there a way to call the 'item[i].title' part of each parsed XML variable ... as a standard call without having to hard code each RSS feed's unique XML structure individually? You see ... the RSS feed URLS are fed dynamically from my web site ... and hardcoding would be impossible.
Thanks!
R
ASKER
Thanks. BUT ... problem - when I use xmlsearch ... the multiple rss.channel.item[i].title values ... aren't placed into an array. ..
instead ... the multiple sub components of item[i] are sequentially listed; ..
i.e. item[1].xmltext = title
i.e. item[2].xmltext = description
i.e. item[3].xmltext = text
etc
instead ... i need ...
item[1].title.xmltext
item[2].title.xmltext
item[3].title.xmltext
make sense!?
Richard
instead ... the multiple sub components of item[i] are sequentially listed; ..
i.e. item[1].xmltext = title
i.e. item[2].xmltext = description
i.e. item[3].xmltext = text
etc
instead ... i need ...
item[1].title.xmltext
item[2].title.xmltext
item[3].title.xmltext
make sense!?
Richard
Just loop through them and build your array.
<cfif item[x].XmlName eq "title">
<cfset item[y].title = item[x].XmlText />
<cfif item[x].XmlName eq "title">
<cfset item[y].title = item[x].XmlText />
Xsearch can get just the titles also, if that's what your after.
I'd have to look up how.
I'd have to look up how.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Plucka:
Thanks. This kinda works. Problem : each RSS feed has different naming conventions and different XML structure.
How on earth do these RSS aggregators like NetNewsWire understand which fields to strip; for blog title, description and date!? I'm perplexed.
R
Thanks. This kinda works. Problem : each RSS feed has different naming conventions and different XML structure.
How on earth do these RSS aggregators like NetNewsWire understand which fields to strip; for blog title, description and date!? I'm perplexed.
R
ASKER
thanks. found solution.
Use XmlSearch which is CF's version of XPath, search for XPath queries to assist you.
<cfset myXml = XmlParse(xmlVariable) />
<cfset nodes = xmlSearch(configXml, "//items/*") />
<cfdump var="#nodes#" />
This should return all items from your xml.
Regards
Plucka