Search

Hello.

Is there a way for a Symphony page to output nice and clean JSON?

I'm using jQuery to make an Ajax call to retrieve dates of events in JSON format:

$.get(
    url,
    { year: year, month: month},
    function(result){
        ...
    },
    "json"
);

The page XSLT is transforming the resulting DSs' XML very well but the result contains an XML declaration like this:

<?xml version="1.0"?>
[ "1", { start: "2011-04-29", sfarsit: "2011-05-03" },{ start: "2011-05-25", sfarsit: "2011-06-02" } ]

This is definitely the cause of failure for the Ajax call. I noticed that the XML declaration <?xml version="1.0"?> is automatically inserted after the XSLT processing of the XML, line 158 in class.xsltprocess.php:

$processed = $XSLProc->transformToXML($xmlDoc);

Any suggestions?

Thank you.

Have you tried the text output method?

<xsl:output method="text"
    omit-xml-declaration="yes"
    encoding="UTF-8" />

Thanks, Michael.

omit-xml-declaration="yes" did the trick. I didn't know about it.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details