Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2010-01-03 12:40:05

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

Re: smd_xml : extract data from XML feeds

Jaro wrote:

I’m running PHP 5.2.9-1. Let me know if I can help you any further to debug this.

Thanks. Would you try something for me please: modify the plugin and change line 182 from:

xml_set_object($xmlparser, &$this);

to this:

xml_set_object($xmlparser, $this);

then see if a) the warning goes away, b) the plugin still works as it did before. Ta!


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

#14 2010-01-03 12:46:59

Jaro
Member
From: S/F
Registered: 2004-11-18
Posts: 89

Re: smd_xml : extract data from XML feeds

That fixed it. Warning is gone and the plugin works. Thanks!

Offline

#15 2010-01-03 19:04:16

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

Re: smd_xml : extract data from XML feeds

Try v0.2

Features:

  • Pagination / limit / offset (use negative offsets to start from the end of the feed)
  • Cached documents with variable timeout
  • Automatically linkify any links into anchored hyperlinks

Last edited by Bloke (2010-01-03 19:04:33)


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

#16 2010-01-04 11:16:33

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

Re: smd_xml : extract data from XML feeds

not been on the forums for a while – still using Txp daily, hourly! – but always impressed when dropping in … this plugin looks great, bloke … you’re a machine

P.S. I mucked around with that other plugin that takes feeds and inserts them into the db as articles … this might be more flexible, look forward to someone implementing that bit ; )

Offline

#17 2010-01-04 21:09:57

photonomad
Member
Registered: 2005-09-10
Posts: 290
Website

Re: smd_xml : extract data from XML feeds

dang, this is so cool!

I was just giving the plugin a try and it works effortlessly with most xml feeds. I just tried it with a sample feed from artistdata.com and I can’t get it to work…. I’m wondering if it is a problem with the artistdata feed or me (probably), or something that the plugin isn’t catching with regard to the way they do their feeds? This is the ArtistData developers info page

Here is my try at parsing it with the plugin:

<txp:smd_xml data="https://www.artistdata.com/dashboard/feed/ADS-B05XYB0QLMN8D15/17" record="Shows" fields="AgeLimit, City, Country, Date, DoorsTime, EventName, OtherArtist, OtherArtistURL, State, TicketPrice, TicketPurchaseURL, Time, Venue, VenueAddress, VenuePhone, VenuePostalCode, VenueURL" skip="Artist, ArtistIdentifier, ArtistURL, Genre, PartnerArtistIdentifier, ShowIdentifier, Status" linkify="OtherArtistURL, TicketPurchaseURL, VenueURL" wraptag="div" target_enc="iso-8859-1">
AgeLimit: {AgeLimit}<br />
City: {City}<br />
Country: {Country}<br />
Date: {Date}<br />
DoorsTime: {DoorsTime}<br />
EventName: {EventName}<br />
OtherArtist: {OtherArtist}<br />
OtherArtistURL: {OtherArtistURL}<br />
State: {State}<br />
TicketPrice: {TicketPrice}<br />
TicketPurchaseURL: {TicketPurchaseURL}<br />
Time: {Time}<br />
Venue: {Venue}<br />
VenueAddress: {VenueAddress}<br />
VenuePhone: {VenuePhone}<br />
VenuePostalCode: {VenuePostalCode}<br />
VenueURL: {VenueURL}
</txp:smd_xml>

also tried it without as many variables and it still returns nothing:

<txp:smd_xml data="https://www.artistdata.com/dashboard/feed/ADS-B05XYB0QLMN8D15/17" record="Shows" fields="Time" wraptag="div" target_enc="iso-8859-1">
Time: {Time} <br />
</txp:smd_xml>

Any ideas? I hope I haven’t just missed something obvious!

Offline

#18 2010-01-04 21:57:54

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

Re: smd_xml : extract data from XML feeds

photonomad,

I first thought that the feed url you are referencing is only retrievable when you’re logged in, but that doesn’t seem to be the case.

You sure your server allows fopen wrappers?
And have you checked your php error log yet?


Kensington TXP powered rock

Offline

#19 2010-01-04 23:12:23

photonomad
Member
Registered: 2005-09-10
Posts: 290
Website

Re: smd_xml : extract data from XML feeds

No errors in my php error log and my php.ini was set to allow_url_fopen. I just tried it with allow_url_fopen On and then switched it to Off – still no errors either way. The xml feed that I tested from upcoming.yahoo.com works fine, but the artistdata xml feed returns nothing. I’ve got Textpattern in debugging mode and no errors show there either. hmm…

Offline

#20 2010-01-04 23:13:39

Zanza
Plugin Author
Registered: 2005-08-18
Posts: 699
Website

Re: smd_xml : extract data from XML feeds

Don’t know if this is related, but the feed Photonomad posted does not validate. It could be a problem, given the way this plugin works (just asking Bloke)?

Offline

#21 2010-01-05 10:58:48

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

Re: smd_xml : extract data from XML feeds

photonomad

Nothing you’re doing wrong; it’s me. The plugin can’t handle https:// feeds because I hard-coded the port to 80. D’oh!

If you switch debugging on in the plugin (debug="3" is the highest level and shows the feed source) you’ll see that the plugin receives a 301 Redirect instead of the proper feed in your case.

[ Incidentally, you don’t need to skip fields if you’re not using them; the only time you need to skip them is if they clash with ones you want to pull out. My rule of thumb is that if you have a sub-node inside your record that uses the same field as one of the ones you are pulling out then you should skip the node. Otherwise you can save yourself some typing! ]

I’ve fixed the feed thing in v0.21. Many thanks for the report, hope that gets you going. I’ve also added a few other attributes:

  • defaults allows you to set default values for any nodes that are empty
  • set_empty is a shortcut that makes sure that all empty nodes are set as empty instead of showing up as {Replacement Tag} in your output
  • transport allows you to force the HTTP transport mechanism of how the feed is fetched (shouldn’t ever need this)

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

#22 2010-01-05 18:24:11

photonomad
Member
Registered: 2005-09-10
Posts: 290
Website

Re: smd_xml : extract data from XML feeds

Bloke

You Rock!! : )

Offline

#23 2010-01-05 20:03:39

photonomad
Member
Registered: 2005-09-10
Posts: 290
Website

Re: smd_xml : extract data from XML feeds

I’m also curious about formatting times and dates. I wouldn’t know how to program it. Writing from a user’s point of view, might there be a way to trigger the plugin (maybe with parentheses or something) to format a field on output somehow like this:

feed example:
<Date>2008-11-15</Date>
<Time>20:00:00</Time>

maybe the plugin output could be written like this:
{Date(‘D, M jS’)} at {Time(‘g:ia’)}

and the end result:

Saturday, Nov 15th at 8:00pm

I’m sure it is more complicated to implement, but I thought I’d throw it out here anyway!

Offline

#24 2010-01-06 08:31:48

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

Re: smd_xml : extract data from XML feeds

photonomad wrote:

I’m also curious about formatting times and dates.

Me too. I had a look for a date-based reformatting plugin but none exists as far as I can make out. Yet… :-) The closest is <txp:smd_cal_now /> in smd_calendar. If you happen to have that installed you can probably use it to reformat (most) English-looking dates.

Sadly, the syntax you specified is rather difficult to implement. But I may be able to add an attribute to the plugin itself that allows you to format stuff. For example format="Date|datetime|M-d-Y, DoorsTime|datetime|H:m:s" and so on but I’d rather not have to do it because it means the plugin becomes limited. In other words, where does it end? If you wanted to truncate the output you could use rvm_substr in your Form/container but some might argue that the plugin should be able to do it natively with format="SomeField|truncate|8". Or if you wanted to convert a field to an integer or something like that. So if I do date manipulation the formatting features potentially never end!

However, it is a useful facility so I might do it if I can find a way. Or I might write/find a date formatting plugin instead :-)


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

Board footer

Powered by FluxBB