Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#61 2010-07-06 18:09:31

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 605
Website

Re: smd_xml : extract data from XML feeds

Need some help here please,
this is my first time trying this plugin.

I got a feed from Beatport: for example this one .
And I want to grab the 3 self closing <link /> tags.
or the whole <content> tag data.
(What I need are the MP3 links)

so my code is this:

<txp:smd_xml data="http://feedlink..." record="entry" fields="title, link, content">
<div>
{title}
<br />
{link}
<br />
{content}
</div>
</txp:smd_xml>

and the only thing that works is the “title” field.
how can I grab the others please?

Offline

#62 2010-07-06 19:42:33

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,736
Website GitHub

Re: smd_xml : extract data from XML feeds

THE BLUE DRAGON wrote:

this is my first time trying this plugin.

Then I’m sorry to report the plugin isn’t quite up to your challenge in its current guise. It’s a bit rubbish with self-closing links. You can have a copy of my dev version (which isn’t finished but mostly works with your example feed) if you get in touch with me. You can grab the links with {link|href}, {link|rel}, and {link|type}.

The other issue that even the new version has, is that your feed isn’t true XML. Well, it is but halfway through each record is a block of XHTML which the plugin tries to interpret as XML. Not sure how to handle that — might need some kind of raw option in the plugin to treat certain content as non-XML. Will have a think about it, but for now if you don’t need the stuff inside the content block I’d be tempted to skip it just to be safe.

One other bizarre thing I found is that if you use &resultsPerPage=10 in the feed you get complete gibberish out of the feed. Any other value (5, 9, 11, 20, whatever) is fine and the feed is read properly. I have absolutely no idea why 10 is destroying the feed integrity. Totally weird.

Last edited by Bloke (2010-07-06 19:44:24)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#63 2010-07-06 20:07:42

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 605
Website

Re: smd_xml : extract data from XML feeds

Bloke wrote:

but for now if you don’t need the stuff inside the content block I’d be tempted to skip it just to be safe.

All I need is the titles and the mp3 links.
I want to create a page and open it in an iframe from the Write admin page,
and let the client to just choose the file and it will automatically grab the link of the mp3 and paste it in a custom-field.
just like the cool bot_image_upload plugin.
and from what I was reading in google is that the page inside the iframe must be on my server to be able to manipulate it using jQuery.
so if in the dev version that you got I will be able to grab the <link> tags as you mentioned, so yea I think it will work.

Last edited by THE BLUE DRAGON (2010-07-06 20:09:03)

Offline

#64 2010-07-14 13:29:14

kevinpotts
Member
From: Ghost Coast
Registered: 2004-12-07
Posts: 370

Re: smd_xml : extract data from XML feeds

Bloke wrote:

bc. <txp:smd_xml data=“http://weather.yahooapis.com/forecastrss?w=2362700” record=“channel” fields=“yweather”>
Sunrise: {yweather:astronomy|sunrise}
Sunset: {yweather:astronomy|sunset}
</txp:smd_xml>

Stef —

Tried this exact syntax and the beta plugin does not output the data for the replacement tag. I also tried fields="yweather:astronomy" and also outputting via a form instead of inside enclosed tags, but all that outputs is this:

Sunset: {yweather:astronomy|sunset}

I know this is beta functionality, but there is a good chance I am doing something wrong.


Kevin
(graphicpush)

Offline

#65 2010-07-14 13:45:23

nardo
Member
From: tuvalahiti
Registered: 2004-04-22
Posts: 743

Re: smd_xml : extract data from XML feeds

Stef – this plugin is versatile, useful in so many contexts – keep at it boss

Offline

#66 2010-08-01 23:11:05

krystal
New Member
Registered: 2010-07-29
Posts: 5

Re: smd_xml : extract data from XML feeds

OK, yaay me, I installed my first plugin (said the excited newbie)! Can it be used for importation of blog-type files stored on one’s hard drive? If so, how should I proceed, since I am not a php coder, either…

thanks

Offline

#67 2010-08-31 17:56:57

AndrijaM
Member
From: Belgrade, Serbia
Registered: 2007-12-22
Posts: 190
Website

Re: smd_xml : extract data from XML feeds

Hello, does anybody has any idea why this code

<txp:smd_xml data="http://news.google.com/news?pz=1&cf=all&ned=us&hl=en&q=%D0%A0%D0%BE%D1%81%D1%81%D0%B8%D1%8F+%D0%A1%D0%B5%D1%80%D0%B1%D0%B8%D1%8F+%D0%B1%D0%B8%D0%B7%D0%BD%D0%B5%D1%81&cf=all&output=rss" record="item" fields="title, link" wraptag="ul" limit="5">
   <li><a href="{link}">{title}</a></li>
</txp:smd_xml>

does not want to output 5 headlines, just 2 always even if I change 5 to 10 or any other number?

Help would be much appreciated!

Offline

#68 2010-08-31 20:02:19

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,736
Website GitHub

Re: smd_xml : extract data from XML feeds

AndrijaM wrote:

Hello, does anybody has any idea why this code <snip> does not want to output 5 headlines, just 2 always

Yes. It’s because of Google’s insistence at making code as unreadable as possible in its quest to reduce the number of bytes served to browsers. They remove every jot of unnecessary whitespace — which makes the feed appear on one loooooooong line (look at the feed source code). The plugin has a default line legth of 8192 characters, so it’s only seeing around 2 <item>’s worth of information.

The plugin docs have some examples on this. I suggest you experiment with the transport="curl" attribute and — if that fails — try increasing the line_length attribute. That should sort it out.

Last edited by Bloke (2010-08-31 20:03:12)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#69 2010-09-01 12:37:13

AndrijaM
Member
From: Belgrade, Serbia
Registered: 2007-12-22
Posts: 190
Website

Re: smd_xml : extract data from XML feeds

Thank you Stef, transport=“curl” solves the problem :)

Offline

#70 2010-11-04 20:00:58

rickoshay
New Member
From: California, USA
Registered: 2010-10-28
Posts: 2
Website

Re: smd_xml : extract data from XML feeds

I love this plug in! I was searching for a good XML/RSS solution for my site when I found this using a google search. I didn’t even know Textpattern existed, now I’m hooked. I am eternally grateful to Bloke for this.

Quick question:
photonomad wrote:
feed example: <Date>2008-11-15</Date <Time>20:00:00</Time>

I am using a feed similar to photonmad here: http://artistdata.sonicbids.com/shades-of-day/shows/xml/future

Bloke wrote:
format attribute which allows you to further manipulate each field in a variety of ways prior to seeing it in the form/container.

I am trying to format both the date and time.

Here is my current textpattern code:

<txp:smd_xml data="http://artistdata.sonicbids.com/shades-of-day/shows/xml/future" record="show" fields="name, venueName, venueZip, venuePhone, venueAddress, ageLimit, venueURI, date, timeSet, ticketPrice, stateAbbreviation" format="date|date|%a-%e-%Y", "timeSet|time|%l:%M"> <p>{date} {name}</p> <p>Set Time: {timeSet}</p> <p>COST: {ticketPrice}</p> </txp:smd_xml>

What I get is:

UPCOMING DATES
{date} {name}
Set Time: {timeSet}
COST: {ticketPrice}

I am stumped. How do I format both the date and time properly?

p.s. This is my first post to the forum, I hope this is all clear.

Offline

#71 2010-11-04 23:36:25

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,736
Website GitHub

Re: smd_xml : extract data from XML feeds

rickoshay wrote:

I didn’t even know Textpattern existed, now I’m hooked. I am eternally grateful to Bloke for this.

Thanks for the props and glad you found us. I’d never heard of TXP either back in ’06 and it was a random link to a Jon Hicks site that led me on this path. In’t the interweb terrific!

Anyway, onto your problem, I think it’s just a slight syntactical snafu in your format attribute. You have:

format="date|date|%a-%e-%Y", "timeSet|time|%l:%M"

Which, according to the parser, sees the end of the format attribute after the second double quote, then a spurious comma in the tag and then some other timeSet ‘stuff’ in double quotes that it feels duty bound to ignore because it doesn’t understand it.

What you probably need is this:

format="date|date|%a-%e-%Y, timeSet|time|%l:%M"

which makes the format attribute one string, housing two things separated by a comma.

Give that a whirl and see how you go.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#72 2010-11-05 00:28:12

rickoshay
New Member
From: California, USA
Registered: 2010-10-28
Posts: 2
Website

Re: smd_xml : extract data from XML feeds

Bloke wrote:

What you probably need is this:

format="date|date|%a-%e-%Y, timeSet|time|%l:%M"

Thanks so much for the quick response! I copied in the new code and it got pretty close. The output I got was:

Sat-13-2010 TAKE ALL NIGHT Album Release Show and Celebration

Set Time: 20:00:00.0000000

COST: $15

This was good because the output was no longer getting blasted away by the plugin and the date was formatted nicely but the time still looked like it was from another planet.

So, I went to work on formatting the time by itself just to make sure it could be formatted. I used format="timeSet|time|%l:%M" but had no luck.

Then I used format="timeSet|date|%l:%M" SUCCESS! Well, now I put them both together using format="date|date|%a-%e-%Y, timeSet|date|%l:%M"

The output was:
Sat-13-2010 TAKE ALL NIGHT Album Release Show and Celebration
Set Time: 8:00
COST: $15
PAST DATES

GOT IT! The plugin was being confused by the fact that I was using timeSet|time when I should have been using timeSet|date for both.

Many thanks Bloke! You really saved me on this one.

Offline

Board footer

Powered by FluxBB