I’m having a trouble running XPath on some hebrew content.
My code:
$strGames = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><Array1 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://tempuri.org/\"><Live><Name>שלום</Name><ID>11113</ID></Live></Array1>";
$Games = new SimpleXMLElement($strGames);
$live = $Games->xpath("/*[local-name()='Array1']/*[local-name()='Live' and contains(.,'שלום') and namespace-uri()='http://tempuri.org/']");
The ‘$live’ variable contains an empty array after executing it.
If I’m executing with “contains(.,’11113′)” – I’m geting the result – so the problem is
definately in the hebrew part.
What can be the problem ?
Try changing the encoding in your
$strGamesto UTF-8.Also make sure your editor is set to read/write documents as UTF-8.
Hope this helps.