Export XML


Search results from a query saved in the query directory can be exported in XML format.

Example of use: export future news in reverse chronological order

1) Execute the search for future news

In the back-office tool, open the search tool Solr and search for your future news.

Here's an example of how to search for FR content of the "News" type, with at least one tag in the "News" category and a start date greater than or equal to today

Types of content : News
Request :  site:www AND contentLanguage:fr AND allTags:ACTUALITES AND start-date_dt:[NOW TO *]

In the Column field, add the fields you wish to export (use the Ctrl+Space autocomplete function to view the available fields).

Columns : title, start-date, end-date, illustration.image, illustration.alt-text, content, tags

To save the sorted results, run the search once, then sort in the desired order by clicking on the column headers. Here, by reverse start date and reverse end date.

2) Save search

Then save the query in the query directory :

The saved search appears in your query directory and can be replayed at any time.

By default, the search is private and therefore accessible only to the user who created it.

3) URL export results

TheURL export form is:
http://[URL_SITE]/remote/_query/ws/export.xml?queryId=[IDENTIFIANT_QUERY]

Copy the query identifier from the contextual ribbon

By queryingurl from the site application, you are guaranteed to export the results in their validated version.

If you wish to use this URL to access the export, avoid criteria based on the workflowStep property, which is not supported on the live side, as you run the risk of having no results in your export.

If you don't have a site application, you can use the CMS server directly.
url would then look like this:
http://[CMS _SITE]/remote/_query/ws/export.xml?queryId=[IDENTIFIANT_QUERY]&versionLabel=Live
Please note: in this case, you need to add &versionLabel=Live to retrieve the validated version of the content. Otherwise you'll get the draft version.

Case 1: Export and research results are public

Select your query and choose to make it public (Visibility menu -> Public).

Make sure that the results of this search are also available for an anonymous user to read.

Case 2: Export and search results are read-protected

If your query is private or shared, you must be authenticated to access the query and its results.

Theurl export can be authenticated using a token.

Generate an authentication key from the back-office user menu and copy it.

To queryurl with your authentication key, you need to pass your key in a POST request parameter named "token".
The export will then contain the results readable by the user with this token.

Please note that transmission of the authentication key using the GET method is not authorized, so you must use the POST method to queryurl .

4) Results transformation

Without further processing, the search results are exported in their "raw" form. In particular, rich text will be exported in Docbook storage format, without resolving links or images.

It is possible to add a XSL transformation to the exported XML feed, allowing rich text to be exported in HTML format and links to be resolved.

To do this, place the file XSL in the WEB-INF/stylesheeets/export directory of the back-office application and callURL export, adding the name of the file XSL to be used in the query parameter "xslt " .
http://[URL_SITE]/remote/_query/ws/export.xml?queryId=[IDENTIFIANT_QUERY]&xslt=[FILENAME]

 

The XSL default.xsl transformation tool, shown here as an example, exports rich text content in HTML format and resolves links with absolute URL pointing to the site.

 

 

Back to top

Queries Directory