Textpattern Forum

You are not logged in. Register | Login | Help

#1 2010-01-02 13:14:29

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 5,905
Website

smd_xml : extract data from XML feeds

The first plugin of the new decade arrives. This one is a kind of generic XML processor. Give it a URL (e.g. a feed) that returns well-formed XML and then use the plugin to filter out stuff from the various records.

  • Include, or exclude any node information
  • Automatically extract XML attribute data and manipulate it
  • Use a Form or the plugin container to restructure / output data you have extracted
  • Add custom pagination to your document to allow visitors to step through your data

It uses the, by now, familiar {replacement tag} syntax that wet pioneered and I stole so you can reformat the information from the XML document for your own purposes. Although untested, an interesting experiment might be to grab feed data from somewhere on the web and use smd_query in the container to INSERT parts of the data into your TXP database. As far as I know there are no restrictions on what you can and can’t grab from the XML document so if you can see it, you can muck about with it.

Download the plugin and get XMLing.

As ever, post any thoughts, improvements, bugs, praise, or flaming pitchforks here and I’ll tend to the village.

Happy New Year!

Revision history
————————

All available versions and changes are listed here. Each entry indexes the relevant post(s) in the thread to learn about the features.

Last edited by Bloke (2010-01-17 12:41:14)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern.

Txp Builders – finely-crafted code, design and Txp

Offline

#2 2010-01-02 14:58:32

variaas
Plugin Author
From: Chicago
Registered: 2005-01-16
Posts: 402
Website

Re: smd_xml : extract data from XML feeds

Looks awesome – any plans for caching capabilities? Pinging Twitter every page load can become excessive.

Offline

#3 2010-01-02 19:09:57

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 5,905
Website

Re: smd_xml : extract data from XML feeds

variaas wrote:

any plans for caching capabilities?

Hadn’t thought about it, but it makes sense. Leave it with me.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern.

Txp Builders – finely-crafted code, design and Txp

Offline

#4 2010-01-02 21:11:23

LetterHoofd
Member
From: Kortrijk, BE
Registered: 2006-01-20
Posts: 40
Website

Re: smd_xml : extract data from XML feeds

This plugin looks very promising. Might be a true timesaver.

Offline

#5 2010-01-03 01:56:14

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

Re: smd_xml : extract data from XML feeds

I was exactly looking for this when I stumbled upon it being the newest submission, awesome :)
Tried it out really quickly, and seems to work very well!

One feature that may be useful: a limiter on the amount of entries you want to import.
That way you could, for example, show the last 3 posts from some blog on your site.

If you agree, then perhaps an offset parameter is possible too? (Since that could be added without much extra effort).

If the things I’m suggesting are already possible, slap me, it’s already 3 AM.. :-)

Anyway, good job!

Last edited by jan (2010-01-03 01:56:54)


Kensington TXP powered rock

Offline

#6 2010-01-03 02:04:22

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 5,905
Website

Re: smd_xml : extract data from XML feeds

jan wrote:

I was exactly looking for this when I stumbled upon it being the newest submission, awesome :)

Excellent, glad it’s potentially useful.

… a limiter on the amount of entries you want to import.

Hehe, are you a mind reader? I’m adding limit, offset and paging features to the plugin right now so you can step through the records if you want :-) It’s a bit of a cheat because you can’t very easily grab part of an XML document, but it seems to work.

Variaas’ cache capability is coded and working already, so watch this space…

it’s already 3 AM

Only 2am here: the night is young… :-)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern.

Txp Builders – finely-crafted code, design and Txp

Offline

#7 2010-01-03 02:13:57

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

Re: smd_xml : extract data from XML feeds

Haha, maybe I imported an xml feed of your thoughts?
Anyway, I “fell with my nose in the butter” like the Dutch say.
Curious for 0.2! :D

Last edited by jan (2010-01-03 02:14:41)


Kensington TXP powered rock

Offline

#8 2010-01-03 11:30:14

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

Re: smd_xml : extract data from XML feeds

Great plugin!

Would there be a way to define a date/time format in the output? Also it would be great if all links in the output would be automatically clickable (e.g. bit.ly links used in Twitter).

Offline

#9 2010-01-03 11:36:43

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 5,905
Website

Re: smd_xml : extract data from XML feeds

Jaro wrote:

Great plugin!

Ta. Documenting the next version today…

Would there be a way to define a date/time format in the output?

Not yet. I did think it would be useful, but couldn’t think of a decent way of doing it. Any ideas how to best specify it without making it too messy or clumsy?

it would be great if all links in the output would be automatically clickable (e.g. bit.ly links used in Twitter).

Saw your other post and thought it was a good idea, so I’m workin’ on it!


The smd plugin menagerie — for when you need one more gribble of power from Textpattern.

Txp Builders – finely-crafted code, design and Txp

Offline

#10 2010-01-03 11:49:42

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

Re: smd_xml : extract data from XML feeds

Bloke wrote:
Not yet. I did think it would be useful, but couldn’t think of a decent way of doing it. Any ideas how to best specify it without making it too messy or clumsy?

No, not really, sorry. I’m not really good with php.

I noticed one thing. When I active this plugin I get a warning:

Warning: Call-time pass-by-reference has been deprecated in C:\wamp\www\mysite\textpattern\lib\txplib_misc.php(594) : eval()'d code on line 182

I’m running 4.2.0 (r3275) on localhost.

Offline

Board footer

Powered by FluxBB