Search

I have a dynamic data source that grabs articles from an external resource. For the site I need search functionality: Does anybody know if there is a way to parse my external XML and make it searchable (with PHP in an extension or using XSLT itself)?

If I enter keywords that parser should only return nodes containing the search terms.

The simplest way would be using XSLT:

my-external-ds/entry[contains(*,$search-term)]

Which will find any entry where a child node contains a certain piece of text. Alternatively you might want to pull the feed into a Symphony section at which point you could query it using regexp from a Data Source.

Or if you are comfortable writing PHP you could write a script which opens the PHP, parses the nodes and uses a preg_match on each node text() so that you can match with a regular expression. This script would then return the XML that matches your search — a middle-man.

If you go into PHP, I believe the SimpleXML api will let you apply XPath as well.

Yes indeed. Although I think contains() is case-specific though. But it depends on the type of search you need to do.

Thanks guys, I’ll think about the different solutions.

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