I have an XML document:
<items>
<item>
<id>1</id>
<title>Title ABC Defg</title>
<author>Author Name</author>
<description>Description text </description>
</item>
...
</items>
And i would like to do a serching and check title, author, description if contains a phrase
I dont know how to do it at once and order it by relevancy. But it is not such important as searching for "Word" and "word". I used the php code:
<?php
$xml=simplexml_load_file(file.xml);
$query=$_GET['query'];
$nodes= $xml->xpath("//item[contains(title,'$query')]");
$count = count($nodes);
for ($i=1;$i<=$count;$i++){
$nodes= $xml->xpath("//item[contains(title,'$query')][$i]");
foreach($nodes as $node) {
$title = $node->title;
$desc= $node->description;
$auth= $node->auth;
$id= $node->id;
echo "id: $id<br />title: $title<br />author: $auth<br />desc: $desc<p> </p>
?>
I know it searches only titles but the problem is that when i search for Word it cant find word and i would like to get both : word and Word
If you could also help me with "connecting" searching in author title and description and to order it somehow i would really appriciate.
EDIT:
I have manage to search in all tags (not only specified but for me it is ok)
so i have code like this:
$query=strtolower(rawurldecode($_GET['s']));
$nodes= $xml->xpath("//item[contains(translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'),'$query')]") // . - all i suppose
i also use kind of validation of $query