Al Ingham

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromAl Ingham
ToMe
SubjectXML Parser
Date13 October 2006 09:04
Hi
Just wanting to possibly use your script on my website - with your
permission of course! I am wanting to just display the first couple of posts
from my xml feed from [URL], and not wanting to display every single
post on my main page.
Hopefully your script can allow for that?


Cheers,

Al Ingham
FromMe
ToAl Ingham
SubjectRe: XML Parser
Date13 October 2006 19:11
Al,

> Just wanting to possibly use your script on my website - with your
> permission of course!

You do not need to ask permission for non-commercial sites. Please just
follow my license terms of use for personal sites :)
http://www.howtocreate.co.uk/jslibs/termsOfUse.html

> I am wanting to just display the first couple of posts
> Hopefully your script can allow for that?

Not built into the script, but it should be a fairly simple modification to
the RSS/Atom parser script.

Look for this comment in the source code:
//now that the entire feed has been converted into JavaScript arrays,...
And put this above it:
if( newsItems.length > 2 ) { newsItems.length = 2; }

That should do it.


Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
FromAl Ingham
ToMe
SubjectRe: XML Parser
Date13 October 2006 22:03
Sweet

Thats awesome!!! And whats more - it worked first time!!!

Just a question: I am wanting to impliment this for my own site, in that I
don't want to be able to choose the feed that I am displaying, but rather
just have a set feed ([URL])
load automatically...
I've had a quick play around myself, but I don't know javascript and can't
work out how to load the xml automatically and without using the form
(submit button that post the variables etc...)
If you have any ideas I would be grateful. As you can appreciate, modifying
other people's code is not always the easiest of things - especially with
limited knowledge in the language!

If you are too busy, don't fret yourself, I will continue to plow my way
through your code and hope I stumble upon the solution.

Cheers,

Al.
FromMe
ToAl Ingham
SubjectRe: XML Parser
Date13 October 2006 22:36
Al,

> just have a set feed load automatically...

http://www.howtocreate.co.uk/emails/GeorgeFisher.html
or for something smarter ...
http://www.howtocreate.co.uk/emails/MarkKeys.html
FromAl Ingham
ToMe
SubjectRe: XML Parser
Date13 October 2006 23:08
Sweet
I checked out the second one - "for something smarter" and although I don't
need it scrolling, nor do I need it to display multiple feeds, it worked
great by just using one feed in the array; but the code is there in case
this changes!

Superb!
Thanks for your help.
Best wishes for the future.

Al
FromAl Ingham
ToMe
SubjectRe: XML Parser
Date15 October 2006 21:36
One last thing

I am wanting to display the date of when the post was made for my blog, for
each individual entry at the bottom of each entry.
I've had a play around and can't get it to display...

Is there a quick and easy solution to this which I am missing?

Cheers,

Al Ingham
FromMe
ToAl Ingham
SubjectRe: XML Parser
Date16 October 2006 09:58
Al,

> I am wanting to display the date of when the post was made for my blog,
> for each individual entry at the bottom of each entry.

Every fed item in the array has properties matching the (lower case) names
of every element that was in the feed item source. So this:
<item>
  <foo>bar</foo>
  <baz>qux</foo>
</item>

will produce this:

newsItems[0].foo == 'bar'
newsItems[0].baz == 'qux'

Assuming you want them before the final </div> tag of each displayed item,
after this line:

if( displayEnclosures == 2 ) { oFeedStr += oEncl; }

add this:

if( y['pubdate'] ) { oFeedStr += y['pubdate']; }

Assuming the feed items use <pubDate> it will work. If they use something
else, change pubdate to whatever your feed uses.
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.