I have an XML document full of "producers":
<producer>
<name></name>
<owner></owner>
<address>
<civic></civic>
<mailing/>
<town></town>
<province></province>
<postal></postal>
<phone></phone>
<fax></fax>
<email></email>
<website/>
</address>
<products>
<product></product>
<product></product>
<product></product>
<product></product>
<product></product>
<product></product>
<product></product>
</products>
<exports>
<region></region>
<region></region>
<region></region>
<region>l'Amérique du Nord</region>
</exports>
</producer>
For example I want to search for the phrase "l'Amérique du Nord", which is one of the regions for this particular producer:
$query = "l'Amérique du Nord";
$xml = simplexml_load_file("../business-directory/producers-fr-nb.xml");
$upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZÀÂÆÇÈÉÊËÎÏÔŒÙÛÜ";
$lower = "abcdefghijklmnopqrstuvwxyzàâæçèéêëîïôœùûü";
$nodes = $xml->xpath('//producers/producer[descendant::*[contains(translate(text(), "'.$upper.'", "'.$lower.'"), "'.$query.'")]]');
It didn't work. I determined the problem to be when I store the phrase "l'Amérique du Nord" in the string $query. When I echo $query I get this: l'Amérique du Nord
I've used functions like htmlspecialchars() and htmlentities() to try encode the é but nothing seems to work. Any ideas?
Thanks!
Look ma, I answered :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.