Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2017-04-07 12:09:18

Gallex
Member
Registered: 2006-10-08
Posts: 1,294

export articles in xml

i’m not familiar with the topic at all.
so, client wants to export a bunch of real estate articles (text, images) in .xml into other site. is it possible and how difficult this is?

Offline

#2 2017-04-07 12:33:01

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

Re: export articles in xml

Not difficult. Once you know the format of the XML strcuture the external site requires, I would proceed as follows:

  • Make a temporary, hidden Section in your site with a random name (like export_to_xml).
  • Make a Page template assigned to that Section.
  • In your template, use <txp:article_custom> as a container and design your xml structure around it, placing txp:tags where you want the content injected, just like you would with HTML.

e.g.:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<records>
<txp:article_custom section="your-articles-section" limit="999" wraptag="record">
<title><txp:title /></title>
<content><txp:excerpt/> <txp:body /></content>
<photo><txp:article-image /></photo>
<number_of_rooms><txp:custom_field name="rooms" /></number_of_rooms>
...
</txp:article_custom>
</records>

Then just visit that Section of your site to view the XML document. Use ‘Save As’ to export it.

EDIT: you might have to export/download the images separately as they’ll only be URLs in the feed. Or find a way to embed them as BASE64 images or something.

Last edited by Bloke (2017-04-07 12:36:35)


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

#3 2017-04-07 13:52:34

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

Re: export articles in xml

What Stef said but you could use rah external so as to save you creating a new section


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

Offline

Board footer

Powered by FluxBB