Searching XML
This is an open discussion with 4 replies, filed under XSLT.
Search
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.
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.