Maison >développement back-end >tutoriel php >XML文件空格符有关问题
XML文件空格符问题
XML文件
<br /><?xml version="1.0" encoding="utf-8"?><br /><Location><br /> <CountryRegion Name="Afghanistan" Code="AFG"><br /> <State ><br /> <City Name="Herat" Code="HEA"/><br /> <City Name="Kabul" Code="KBL"/><br /> <City Name="Kandahar" Code="KDH"/><br /> <City Name="Mazar-i Sharif" Code="MZR"/><br /> </State><br /> </CountryRegion><br /> <CountryRegion Name="Aland lslands" Code="ALA" /><br /><CountryRegion Name="United?States" Code="USA"><br /> <State Name="Alabama" Code="AL"><br /></CountryRegion><br />
$s = file_get_contents('D:\我的文档\Downloads\全球各国省市(英文版).xml');<br /><br />preg_match_all('/United.+/m', $s, $m);<br />foreach($m[0] as $v) {<br /> echo "$v\n";<br /> echo bin2hex($v), PHP_EOL;<br />}United? Arab? Emirates" Code="ARE">
preg_match_all('/.+\xc2\xa0.+/m', $s, $m);<br />foreach($m[0] as $v) {<br /> echo "$v\n";<br /> echo bin2hex($v), PHP_EOL;<br />}就更多了