我目前正在進行xpath搜索,我有搜索工作,但我需要使其不區分大小寫。我使用的xml文件是1.0,從我的研究意味着我必須使用一些稱爲翻譯功能的東西,但我不確定如何執行此操作。我如何使Xpath搜索不區分大小寫
這裏是我的搜索文件:
$holidayDoc = simplexml_load_file('holidays.xml');
// fetch data from form
$txtSearch = $_GET['txtSearch'];
$qry = "//channel/item[contains(.,\"$txtSearch\")]";
$holidays = $holidayDoc->xpath($qry); // do the xpath query
// now loop through all the students
echo "Showing title search results for $txtSearch";
foreach ($holidays as $holiday)
{
echo "<p><a href=\"{$holiday->link}\">{$holiday->title}</a></p>
<p><small>$holiday->pubDate</small></p>";
任何幫助將不勝感激感謝。
@ alain.janinm:當前接受的答案不正確 - 請參閱我的回答以獲取解釋以及正確的XPath 1.0和XPath 2.0表達式。 – 2012-04-22 15:16:15