Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#181 2012-09-19 20:24:05

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

Re: smd_xml : extract data from XML feeds

etc wrote:

I simply think xpath is a right thing to use here

Much obliged. Note to self: stop putting off learning xpath


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

#182 2012-09-19 21:54:06

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

Re: smd_xml : extract data from XML feeds

etc wrote:

<txp:etc_query url="...youtube..." markup="xml" query="string(//entry/link[1]/@href)" />

provided there is only one entry in the feed.

Thank you both. Unfortunately no, there are more than one entry (one for any video in a playlist I’m trying to parse). I’ll look at your plugin, though (it’s been on my list for a long time, now I’ve finally a good reason).

If you come up with some new idea(s), you’re very welcome!

Z

Offline

#183 2012-09-20 07:28:41

etc
Developer
Registered: 2010-11-11
Posts: 5,188
Website GitHub

Re: smd_xml : extract data from XML feeds

This should import them all (add wraptag or break if necessary):

<txp:etc_query url="...youtube..." markup="xml" query="//entry/link[1]">
  {@href?}
</txp:etc_query>

or

<txp:etc_query url="...youtube..." markup="xml" query="//entry/link[@rel='alternate']">
  {@href?}
</txp:etc_query>

I have not tested https though, welcome to etc_query lawn if somethings goes wrong.

Offline

#184 2012-09-20 08:39:01

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

Re: smd_xml : extract data from XML feeds

Thank you Oleg, I’ll give it a try and report back asap (afternoon, GMT+1…).

Offline

#185 2013-01-25 17:22:44

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,090
Website GitHub Mastodon Twitter

Re: smd_xml : extract data from XML feeds

3 years since the launch of this plugin in this forum, I decided to take a plunge and start experimenting with it.

The premise: We have all our videos on vimeo and we embed them in our site as albums. The problem with albums is that they offer no support for mobile devices so we are using the if_mobile plugin to serve mobile friendly content to those who visit us. Up to now the mobile content for those videos was a link to the album on vimeo. After reading the vimeo api, I realised that this plugin could come to the rescue. I am using the following code:

<txp:smd_xml data="http://vimeo.com/api/v2/album/my_album_id/videos.xml" record="video" fields="id" limit="20">
<iframe class="" src="http://player.vimeo.com/video/{id}?title=0&amp;byline=0&amp;portrait=0" width="229" height="172" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
</txp:smd_xml>

The problem is that although there are 19 videos in the particular album (visible in the xml feed), only five are embedded. Any ideas what I am doing wrong?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#186 2013-01-26 04:32:09

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

Re: smd_xml : extract data from XML feeds

I used your code colak and got six videos…. so I tried using offset of 3 – which missed the first 3 videos, but only showed the last 3 and no more…. is it a vimeo limitation I wonder?

Offline

#187 2013-01-26 05:58:14

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,090
Website GitHub Mastodon Twitter

Re: smd_xml : extract data from XML feeds

tye wrote:

I used your code colak and got six videos…. so I tried using offset of 3 – which missed the first 3 videos, but only showed the last 3 and no more…. is it a vimeo limitation I wonder?

This was one of my thoughts too so I asked a question there and this was the answer from the staff

The simple API is puplic stuff only. Also, it’s cached, so it doesn’t always update right away. The issue is likely one of those two things.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#188 2013-01-26 13:35:19

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,090
Website GitHub Mastodon Twitter

Re: smd_xml : extract data from XML feeds

Thinking about it, I’m not sure that the videos don’t load because of vimeo as I can view them all in the xml.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#189 2013-01-27 04:34:59

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

Re: smd_xml : extract data from XML feeds

yeah – it must be what vimeo said…. the feed I was using has 14 videos, and today I can see them all…. strange

vimeo.com/api/v2/album/61259/videos.xml

Offline

#190 2013-03-16 03:26:38

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: smd_xml : extract data from XML feeds

How to convert the line breaks?

convert="\r\n|something" doesn’t work.

Offline

#191 2013-03-18 04:09:21

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: smd_xml : extract data from XML feeds

I don’t find out how I could implement with this very useful smd_xml plugin what I want. Maybe someone has a good idea. First, I will explain step by step the initial situation:

I have two URLs to retrieve data from a job vacancy database.

With data="https://domain.com?vacancyList=1&user=user&password=password" I become a list of the vacancies. With the plugin I extract from each record three fields: vacancynumber, vacancytitle, jobplace.

With the other URL, data="https://domain.com?vacancy=1&user=user&password=password&vacancynumber=12", if I know the vacancynumber, I become the record of an individual vacancy.

Both URLs works fine with the plugin. But I don’t know how I can make a link from the vacancylist (first URL) to the individual items. My idea is, from each record in the list extract the vacancynumber and pass it to the second URL, and all this “clickable”:

<txp:smd_xml data="https://domain.com?vacancy=1&user=user&password=password&vacancynumber={vacancynumber}"
	record="vacancy"
	fields="jobname, jobplace, description, requirement">
		<h3>{jobname}</h3>
		<p>{jobplace}</p>
		<h4>Description</h4>
		<p>{description}</p>
		<h4>Requirement</h4>
		<p>{requirement}</p>
</txp:smd_xml>

I am grateful for all suggestions and ideas.

Offline

#192 2013-03-19 00:09:52

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: smd_xml : extract data from XML feeds

Please tell me if my question is not understandable.

Offline

Board footer

Powered by FluxBB