I have a company that provides a data feed for a search tool but I must build the search tool. The products inventory changes hourly, which is why they have a feed for the product information. I can pull the feed in to populate a search form where customers can search on my site to see if a product is available by that vendor.
Can someone point me in the right direction to parse the XML feed and display the results as a dropdown in a form? Once they select the first item which is ‘Style’ then a new box should appear called ‘Color’ which again is returned from the feed in a second call (I think it would be a second call passing the parameter the form gathered in the first selection.
I’m not asking anyone to write this for me but I’m new to cURL (which I’m thinking I need to use) and SimpleXML and just need links to good relevant tutorial or some advice.
Well, it’s not very clear how you want things to happen so it’s difficult to give you advice to whether consuming the XML Feed server-side or client side.
Besides, you haven’t explained how you can “obtain” the xml feed. Is it a webservice that requires authentication? What type of request is it? Or it’s simply a file residing in somewhere on the interwebs? Or is it available locally?
I’m going to assume the feed you’re consuming does not require complicated requests or authentication.
So here’s an AJAX example using with jQuery and a GET request
XML Example (productsfeed.xml)
Example HTML with ajax call and a dropdown with products.
Now with PHP
If it’s a webservice you can use cURL
If it’s not a webservice (just a xml file) you can use file_get_contents
To parse the xml and show the dropdown select menu