我有一个名为 的节点的 xml 文件,在标题中我有一个很长的描述。如何使用任何关键字进行搜索并匹配整个字符串?例如我在标题中有这个东西:
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam magna sem, fringilla in, commodo a, rutrum ut, massa. Donec id nibh eu dui auctor tempor. Morbi laoreet eleifend dolor. Suspendisse pede odio, accumsan vitae, auctor non, suscipit at, ipsum. Cras varius sapien vel lectus"
我希望它是这样的,如果我查询“lo”,那么它应该返回所有与 lo 匹配的可能性(不仅是 lo,整个字符串 __> 像 lorem)
源xml:
<?xml version="1.0"?>
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam magna sem, fringilla in, commodo a, rutrum ut, massa. Donec id nibh eu dui auctor tempor. Morbi laoreet eleifend dolor. Suspendisse pede odio, accumsan vitae, auctor non, suscipit at, ipsum. Cras varius sapien vel lectus</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications with XML.</description>
</book>
</catalog>
php代码:
<form method="POST" id="searchform" action="">
<input type="text" name="search_text" id="search_text" />
<input type="submit" name="search" id="search" />
</form>
<?php
$data = (array)simplexml_load_file('axx2.xml');
$data = array_pop($data);
if(isset($_POST['search']))
{
if($_POST['search_text']=="")
{
echo "please enter your search value";
exit;
}
}
if(isset($_POST['search'])){
$equalizing_value=$_POST['search_text'];
$no_of_data_in_xml=count($data);
for($i='0';$i<$no_of_data_in_xml;$i++)
{
$author=$data[$i]->author;
$title=$data[$i]->title;
$genre=$data[$i]->genre;
$description=$data[$i]->description;
}}
?>