First, i know that there are already some questions aubout similar things (Searching an XML file using PHP Load external xml file?), but i CAN'T make ANY PHP, so the following (search.php) is what I copy-pasted in PHP:
<html>
<head>
<title>Search</title>
</head>
<body>
<?php
$search = $_POST["search"];
$xml=simplexml_load_file("inhaltsverzeichniss.xml") or die("Error: Cannot create object");
$result = $xml->xpath('//array/entry/tags[.="$search"]');
while(list( , $node) = each($result)) {
echo '/array/entry/tags: ',$node,"\n";
}
?>
</body>
Then this is my HTML code (in case someone needs it):
<form action="search.php" method="post" >
<input type="text" name="search" placeholder="search for stuff" >
<input type="submit" name="search_button" value="Suche" >
</form>
and this is the XML Document I want to search in (inhaltsverzichniss.xml):
<?xml version="1.0" encoding="UTF-8"?>
<array>
<entry>
<url>Zeitformen Spanisch.odp</url>
<name>Zeitformen Tabelle</name>
<tags>spanisch</tags>
</entry>
<entry>
<url>german-stuff.odt</url>
<name>etwas Deutsches</name>
<tags>german</tags>
</entry>
<entry>
<url>something_english.html</url>
<name>english things</name>
<tags>english</tags>
</entry>
<entry>
<url>other-data.fileextension</url>
<name>cool name</name>
<tags>etc.</tags>
</entry>
</array>
What I want to do is search for tags written in the search form, and give the whole corresponding entry out. (like following:<a href"$url">$name</a><br>Tags: $tags
)
EDIT: this is my current XML with entries with multiple tags (changed it to "tag"):
<array>
<entry>
<url>spanisch/Zeitformen_Spanisch.ods</url>
<name>Zeitformen Tabelle</name>
<tag>spanisch</tag>
</entry>
<entry>
<url>german-stuff.odt</url>
<name>etwas Deutsches</name>
<tag>deutsch</tag>
<tag>spanisch</tag>
<tag>englisch</tag>
</entry>
<entry>
<url>something_english.html</url>
<name>english things</name>
<tag>spanisch</tag>
<tag>englisch</tag>
</entry>
<entry>
<url>other-data.fileextension</url>
<name>cool name</name>
<tag>etc.</tag>
</entry>
</array>