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!

This Dont work, and I dont know why

Status
Not open for further replies.

brantGuy

Programmer
Feb 12, 2007
59
CA
the values are from an xml feed

Code:
insert into ahnFeed
(link, topic, title, pubDate, image, description)
values
('#RIGHT(world.rss.channel.item[x].guid.xmlText, 10)#', 'Sports', '#world.rss.channel.item[x].title.xmlText#', '#world.rss.channel.item[x].pubDate.xmlText#', <cfif IsDefined("#world.rss.channel.item[x].enclosure.XmlAttributes.url#")>'#world.rss.channel.item[x].enclosure.XmlAttributes.url#',<cfelse>'',</cfif> '#world.rss.channel.item[x].description.xmlText#'
 
can you try this?

insert into ahnFeed
(link, topic, title, pubDate, image, description)
values
( '#RIGHT(world.rss.channel.item[x].guid.xmlText, 10)#',
'Sports',
'#world.rss.channel.item[x].title.xmlText#',
'#world.rss.channel.item[x].pubDate.xmlText#',
<cfif IsDefined("#world.rss.channel.item[x].enclosure.XmlAttributes.url#")>'#world.rss.channel.item[x].enclosure.XmlAttributes.url#'<cfelse>NULL</cfif>, '#world.rss.channel.item[x].description.xmlText#'
)

 
Try what Kevin has suggested, and if that doesn't work then put a try/catch around the query, if there is an error then it will be caught by that and the error shown to you. like this:

Code:
<cftry>
<cfquery datasource="">
insert into ahnFeed
(link, topic, title, pubDate, image, description)
values
('#RIGHT(world.rss.channel.item[x].guid.xmlText, 10)#', 'Sports', '#world.rss.channel.item[x].title.xmlText#', '#world.rss.channel.item[x].pubDate.xmlText#', <cfif IsDefined("#world.rss.channel.item[x].enclosure.XmlAttributes.url#")>'#world.rss.channel.item[x].enclosure.XmlAttributes.url#',<cfelse>'',</cfif> '#world.rss.channel.item[x].description.xmlText#')
</cfquery>
<cfcatch type="any">
  <cfdump var="#cfcatch#">
  <cfabort>
</cfcatch>
</cftry>

Hope this helps!

Tony
 
Hi

this is the error im getting

Element ENCLOSURE.XMLATTRIBUTES.URL is undefined in a Java object of type class coldfusion.xml.XmlNodeMap referenced as


as you can tell, im consuming an xml news feed for sports to but on my site. instead of directly displaying the xml on the site, im saving it to cd and feed up the db info to the visitors.

now, in this feed only some stories have pictures this is whats causing the problem
 
Try this:
Code:
<cftry>
<cfquery datasource="">
insert into ahnFeed
(link, topic, title, pubDate, image, description)
values
('#RIGHT(world.rss.channel.item[x].guid.xmlText, 10)#', 'Sports', '#world.rss.channel.item[x].title.xmlText#', '#world.rss.channel.item[x].pubDate.xmlText#', <cfif IsDefined("#world.rss.channel.item[x].enclosure.XmlAttributes.url#")>'#world.rss.channel.item[x].enclosure.XmlAttributes.url#',<cfelse>[b]NULL[/b],</cfif> '#world.rss.channel.item[x].description.xmlText#')
</cfquery>
<cfcatch type="any">
  <cfdump var="#cfcatch#">
  <cfabort>
</cfcatch>
</cftry>

Make sure the columnname 'image' allows NULL.

____________________________________
Just Imagine.
 
image does accept nulls...

I wonder if there is a status code or a catch all in the xml to determin if "ENCLOSURE.XMLATTRIBUTES.URL" even exist.

sort of like in geo coding, when you get a status code of 200 for when the address cant be located..

Craig

 
THIS IS THE DUMP


insert into mytabele(link, topic, title, pubDate, image, description) values ('7006812975', 'Sports', 'Diving: China Men, Women Dominate At World Championships', 'Wed, 21 Mar 2007 13:37:01 +0000', struct
Detail [empty string]
ErrNumber 0
Message Element ENCLOSURE.XMLATTRIBUTES.URL is undefined in a Java object of type class coldfusion.xml.XmlNodeMap referenced as
Resolvedname [empty string]

 
I just had an idea...its not elegant but I think It will work...if it do I will post my solution here in the next hour...if not, im introducing my laptop to gravity
 
well, it worked so my computer is safe for another day...

this is what I did, and like it said, its not pretty but it does the trick..

my initial feed was setup to include images if they were available. so when I was inserting to the DB if it happened to be missing the image...it would throw an error...

remedy
I modified the feed to forget the images all together and just capture the news stories.

then i got a second feed just pulling stories with images, I match up the second feed id with the first one and where theres a match, i dump the image...

tried it it worked.


Thanks for all the help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top