EnexoOnoma
EnexoOnoma

Reputation: 8836

How can I search using PHP through an XML file and display the results?

I am trying to build a very simple price comparison script.

Until now, I wrote a code that gets some product xml feeds from shops and with the help of XSLT I create a single-global xml of all those input XMLs. I use the XSLT because the shops have different names for elements.

Now I want to take it one step further and I want to create a search form that will display me the products let's say I have the term "laptop".

I know how to create a form, but I need a coding guidance to understand how to make it to search in my XML file (products.xml) and display let's say the

Thank you

Upvotes: 0

Views: 9623

Answers (2)

Waltsu
Waltsu

Reputation: 612

You can use SimpleXML library to parse your xml file. In my opinion SimpleXML is easier to use than xmlreader. Though SimpleXML is introduced on php5.

Upvotes: 2

Rick van Bodegraven
Rick van Bodegraven

Reputation: 179

You might want to check out http://php.net/manual/en/class.xmlreader.php

Using that it is pretty easy to navigate through an XML file and grab all the info you need.

EDIT: On second thought, http://php.net/manual/en/book.simplexml.php is a MUCH simpler way to achieve what you're trying to do. Hence the name, I guess ;)

Upvotes: 2

Related Questions