I know this is supposed to be for SQL, but it is database related. I don't have much PHP experience but I would like to add a search feature into my website. I have an XML backend which stores lists of products. It looks like this:
<?xml version="1.0"?>
<!DOCTYPE product PUBLIC "-//RYE//DTD IMAGEDB 1.0 Strict//EN" "component.dtd">
<product>
<component id="prod1">
<title>First Product</title>
<image src="/images/product1/1.jpg" />
<link href="/products/product1/index.html" />
<feature>First Feature</feature>
<feature>Second Feature</feature>
<feature>Third Feature</feature>
<keyword>key1</keyword>
<keyword>key2</keyword>
</component>
<component id="prod2">
...
</component>
</product>
I'm using jscript to translate this into the proper html for my site. I added keywords to increase the functionality of the search. My dilemma now is how to search through both the features and keywords to extract the link and image from each product that matches the search of a particular string.
From what i understand XPath and XQuery would do this, but I'm kind of lost trying to figure it out. Basically I want a person to be able to type a word in a search field. My site will then search through my XML files to find matching items and then give a page with all the matching results.
My hosting company uses PHP 4.3.3. I've found some XPath & XQuery classes written for 4.3.3, but have no idea what I should be doing with them.
Can someone help me by either suggesting the proper technology to use for searching the xml, or maybe giving me some sample code that might search for a particular string within my xml? I know this is kind of asking a lot, but it would help me out greatly.