Suggestion for creating a search of an external xml

Hi,

Apologies, I know this is outside your usual support.

I am trying to create a simple search facility in a page to access and return results from the Food standards agency hygiene ratings.

Data is accessed via their xml page one of which is below

ratings.food.gov.uk/OpenDataFiles/FHRS158en-GB.xml

I wonder if you super beings could kindly offer some pointers. I am not really sure where to start here.

Thank you in advance

Stef.x

  • Tyler Postle
    • CGO

    Hey Stefanie,

    Hope you’re doing well today!

    This is actually a bit outside my realm of expertise too :p

    I’ll call in one of our SLS staff here(coding experts) so we can get their valuable opinion :slight_smile: perhaps they can pass on some pointers to get you started.

    Keep in mind they deal with more complex threads so may take a little longer to respond. If you have any questions in the meantime just let us know!

    All the best,

    Tyler

  • Jude
    • DEV MAN

    Hey Stef

    Hope you are doing great. Here are some tips on how to go about doing this. Its a simple Web App that you are looking at.

    * The Best way to solve this problem is using XPath. It lets you load the XML into memory and read data from it. Its quite powerful, somewhat like regexes are for text.

    * Here are some good tutorials on how to work with XPath. This one and this one are good starting points. This question on stackoverflow deals with how to solve the exact same problem with some interesting links.

    * The information above may be able to get the search to work, but to make it awesome you need to cache the XML file, I can see that its quite large. Take a look at some articles on caching data like this one and this one

    * Finally its good practice to make sure the front end uses AJAX to search and get and display results. Also allow for filtering based on fields and autocomplete. Im sure you must already know but WordPress comes with jQuery which lets you do this will just a few lines of code or you can try these plugins.

    Hope this helps and all the best with your project

    Cheers

    Jude

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.