Skip Navigation

[Resolved] Generate XML using Views

This support ticket is created 4 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Tagged: 

This topic contains 5 replies, has 2 voices.

Last updated by Luo Yang 4 years ago.

Assisted by: Luo Yang.

Author
Posts
#1876385

I am trying to generate a XML text using Views.
How can I avoid all "<" and ">" characters to be filtered out?

I have already unset "Disable the wrapping DIV around the View" and removed the filter in the Output Editor, but didn't worked.
Also the solutions I have found in this Support (ex. https://toolset.com/forums/topic/need-to-strip-views-formatting/) won't help.

Any idea?
Thanks

#1876553
xml.JPG

Hello,

First, Toolset Views does not filtered out "<" and ">" characters.

I have tried it in a fresh WP installation + the latest version, by these steps:
1) Create a post view, in section "Loop Editor", copy/paste the XML Schema codes from doc:
hidden link
2) Put above post view into a page, and test it in front-end, I can see those XML codes work fine, see my screenshot: xml.JPG

Is there anything missing? please provide detail steps to reproduce the same problem

Second, you don't need the custom codes, you can edit the post view, in section "Loop Editor", enable option "Disable the wrapping DIV around the View", it can remove the wrapper DIV tag without custom codes.

#1876837

Sorry for the misunderstanding.
What I am trying to achieve is that the XML should be output as normal text you can see in a page, not as code in console.
In my case it should loop something like this:

<?xml version="1.0" encoding="utf-8"?> 
      <ads>
          <ad>
              <id><![CDATA[[wpv-post-id]]]></id>
              <title><![CDATA[[wpv-post-title output="sanitize"]]]></title>
          </ad>
      </ads>

Additionally, it should resolve the Types shortcodes properly.

#1877659

Within WordPress the [] will take as a shortcode, it conducts the problem you mentioned above, see WP document:
https://codex.wordpress.org/Shortcode_API

And in your case, you don't need the <![CDATA[ ...]]>, you can display Types shortcode directly, for example:

<?xml version="1.0" encoding="utf-8"?> 
      <ads>
          <ad>
              <id>[wpv-post-id]</id>
              <title>[wpv-post-title output="sanitize"]</title>
          </ad>
      </ads>
#1877697

My problem is that I need the [CDATA[....]], as this view should be used to create a XML feed for an external service and they have a strict syntax protocol for the feed.
That's also the reason why I need a pure, raw text output.

#1877813

Please check the document I mentioned above:
https://codex.wordpress.org/Shortcode_API
Within WordPress, the [] will take as a shortcode, it conducts the problem you mentioned above

You can simply test below codes in a fresh new post:
[CDATA[[wpv-post-id]]]
It won't resolve the shortcode [wpv-post-id]

So there isn't such kind of built-in feature within Toolset or WordPress, you will need to consider custom codes, for example create custom shortcodes to output what you want, see the document I mentioned above.