Print

XML, RSS: read & create

What is XML?

XML stands for “Extensible Markup Language“, a textbased markup language. Designed to structure machine-readable data in a Text-File.

JCI and XML: No Problem!

As the Plugin is called “JSON Content Importer” you might think it can handle only the JSON-Format. But JCI can do more!
It can read XML, converts it into JSON and work with it.

Read XML and convert it to JSON

Just add inputtype=XML to the Shortcode:

[jsoncontentimporterpro nameofthetemplate=... inputtype=XML]
Create XML out of JSON

Create a JCI-Template and put XML-text like the following into the twig-Template Text:

<?xml version="1.0" encoding="windows-1252"?>
<rss version="2.0">
<channel>
  <title>titleexample: {{title}}</title>
  <description>descriptionexample</description>
  <link>http://...link</link>
  <copyright>Copyright 20...</copyright>
  <docs>http://....docs</docs>
  <language>en-us</language>
  <lastBuildDate>Tue, 21 Oct 2019 03:19:24 -0800</lastBuildDate>
  <managingEditor>info@.....com</managingEditor>
  <pubDate>Tue, 21 Oct 2019 12:18:22 -0300</pubDate>
  <webMaster>webmaster@....com</webMaster>
  <generator>JCI</generator>
  <image>
    <url>http://www.....gif</url>
    <title>titleimage</title>
    <link>http://www....imagelink.htm</link>
    <description>descriptionimage</description>
    <width>480</width>
    <height>480</height>
  </image>   
  <item>
    <title>titleitem</title>
    <description>descriptionitem</description>
    <link>http://www.linkitem</link>
    <comments>commentsitems</comments>
    <pubDate>Tue, 21 Oct 2019 07:38:46 -0800</pubDate>
  </item>
</channel>
</rss>

Also add a URL and if needed some more info to get the JSON. When the Shortcode is used, the XML-text is evaluated by twig and code like {{title}} (see XML) is replaced by the JSON-data.

If the previous gave you XML you now can edit the template and insert more twig-code to insert JSON-data. In the end you get a XML-feed out of JSON.

RSS: Special XML

The above XML is a special XML-style called RSS. This is used at Newsreaders or Sliders.
Notice: RSS is sensitive to special chars and chars used for RSS itself.
Therefore you must add some “wrapping-code” with “CDATA” to tell RSS that data is enclosed here and not XML-syntax.

<![CDATA[
text....
]]>

By using “?show=oc” you can remove the WordPress-Template to get pure XML. Read more on that here.

Was this article helpful?
0 out Of 5 Stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.
On this page: