Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#85 2011-02-14 09:18:40

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,299
Website GitHub

Re: smd_xml : extract data from XML feeds

tye wrote:

Just having a bit of a problem with the limit tag.

Gah! A stupid bug, thanks for finding it. Fixed in the next version. For now go and find the following line in the code (line 227 in the official version, around 279ish in the beta) :

$rowinfo['numrecs'] = substr_count($src, '<'.$record.'>');

and swap that last line out for this:

$rowinfo['numrecs'] = substr_count($src, '<'.$record);

The reason is that each record in that particular feed’s structure begins like this:

<entry gd:etag='W/"D0IEQX47eCp7ImA9Wx5aEkU"'>

but I’d (foolishly) assumed that the record headings wouldn’t contain attributes, i.e. you would always have just <entry>. Hope that fixes it for you. I shall nip off for a dose of self-flagellation as penance for my stupiditude.


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

#86 2011-02-14 22:18:11

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

Re: smd_xml : extract data from XML feeds

Thats it – that fixed it!!

Nice one Stef – hold back on the dose of self-flagellation – we need you :)

I thought it was me being stupid – I am 100% sure it was working, then it suddenly stopped.

Thanks for looking at it so quickly – its definitely working now :)

Offline

#87 2011-02-26 16:02:29

jan
Member
From: Utrecht, The Netherlands
Registered: 2006-08-31
Posts: 71
Website

Re: smd_xml : extract data from XML feeds

Dear Stef,

Still enjoying this one very much!
Today I had a small issue though, and I hope that maybe someone could give advice on this.

I use the plugin to read a Twitter user timeline, which is an RSS feed.
This afternoon there was apparently some overload on Twitter’s servers, because the request to http://twitter.com/statuses/user_timeline/{my_user_id}.rss?count=1 went into an infinite loop; the stream never arrived and PHP threw the “maximum execution time exceeded”-error, causing my whole website to fail, haha :)

So I dived into the code, and apparently it stuck between lines 137 and 144, a.ka. the while loop in which the stream is pulled from the external source.

I’m definitiely not that big of an expert on PHP’s curl and fsock functions, but I could see that some kind of a timeout appears to be built in to prevent the script from hanging; the function stream_set_timeout() is used for this.

Is it perpaps possible that the timeout does’t work correctly, or has anyone experienced fatal errors causes by unretrievable feeds?

Any help would be appreciated!

Cheers, Jan


Kensington TXP powered rock

Offline

#88 2011-02-26 17:10:54

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,299
Website GitHub

Re: smd_xml : extract data from XML feeds

jan wrote:

Is it perpaps possible that the timeout does’t work correctly, or has anyone experienced fatal errors causes by unretrievable feeds?

Oops, sorry it brought your site down. I haven’t actually checked this under a non-existent feed situation, which is pretty lax of me. I’ve also learned a bit more since writing this so perhaps I can revisit the code and do it properly. You’re right that the set_timeout() should catch it but perhaps it’s not working as intended.

Can’t think of anything offhand to sort it out now, but I’ll try and whip up a fix next week.

Last edited by Bloke (2011-02-26 17:11:14)


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

#89 2011-03-16 04:57:30

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

Re: smd_xml : extract data from XML feeds

I use this plugin so often — thanks Bloke

Question: could it deal with a CSV data source?

Offline

#90 2011-03-16 09:02:46

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,299
Website GitHub

Re: smd_xml : extract data from XML feeds

nardo wrote:

could it deal with a CSV data source?

If you export your CSV file as XML, yes (Excel permits this :-) Otherwise no.

I can build other protocols in (like aslsw66 proved) but at the end of the pipe must sit a valid XML file for the plugin to work.


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

#91 2011-03-25 04:29:32

aslsw66
Member
From: Canberra, Australia
Registered: 2004-08-04
Posts: 342
Website

Re: smd_xml : extract data from XML feeds

Any news on the super-duper version of this, which allow for attributes on fields?

What, did you think I would forget? Probably a good plan, given my advancing years…

Offline

#92 2011-03-26 19:37:42

bojay
Member
Registered: 2010-04-13
Posts: 11

Re: smd_xml : extract data from XML feeds

Hey Stef and everyone else!
This may be an easy one, but I have some difficulties with using a txp:custom_field inside the data string url.

What I need in a page template is a line like this:
<txp:smd_xml data=“http://www.boardgamegeek.com/xmlapi/boardgame/34?stats=1” record=“ratings” fields=“averageweight” >
And I have the dynamic id (number 34 in the above example) in the custom field called “bggid” for the article being served.

This doesn’t work for me:
<txp:smd_xml data=“http://www.boardgamegeek.com/xmlapi/boardgame/<txp:custom_field name=“bggid” />?stats=1” record=“ratings” fields=“averageweight” >
output: {averageweight}
</txp:smd_xml>

Everything is wrapped in a <txp:if_custom_field name=“bggid”> to make sure I don’t call the smd_xml unless I have content in the custom field.
The setup works if I hard-type the number into the data-sting.

Is there any rendering order that prevents me from this or any suggestions that will trap/generate my data url including my custom field number ?

Thanks
/Bo

Offline

#93 2011-03-26 23:22:02

merz1
Member
From: Hamburg
Registered: 2006-05-04
Posts: 994
Website

Re: smd_xml : extract data from XML feeds

bojay Parsing nested tags needs single quote ' wrapping.

<txp:smd_xml data='http://.../<txp:custom_field name="bggid" />?stats=1' record="ratings" fields="averageweight">

Shorter: 'http://.../<txp:custom_field name="bggid" />?stats=1'

TXP FAQ – Can I use tags within tags?


Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML

Offline

#94 2011-03-27 05:56:56

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

Re: smd_xml : extract data from XML feeds

I’m finding the set_empty attribute isn’t working for me – anyone confirm it works/doesn’t work for them?

  • in the data xml, there is <other_points></other_points>
  • other_points is specified in the attribute fields of smd_xml
  • output is {other_points} on-screen

Offline

#95 2011-03-27 09:10:06

bojay
Member
Registered: 2010-04-13
Posts: 11

Re: smd_xml : extract data from XML feeds

#93:
Thanks a lot Markus Merz – single quotes did the trick !
(now why didn’t I think of that myself .. sigh)

:)

Offline

#96 2011-03-31 03:53:14

aslsw66
Member
From: Canberra, Australia
Registered: 2004-08-04
Posts: 342
Website

Re: smd_xml : extract data from XML feeds

I know that this is not about this particular plugin, but I’m not really sure if any plugin does what I need…

I’ve started using smd_xml to pull in a Twitter feed from another organisation. The problem is that this organisation often puts URLs to their Facebook posts in their Tweets – and sometimes the Tweet is just one long URL (they haven’t figured out about URL shortening yet!).

Is there someway to convert the text returned from the Twitter feed to a link? For example, find anything starting with “http://” and convert that to a link.

Offline

Board footer

Powered by FluxBB