XML文件空格符有关问题

WBOY
Release: 2016-06-13 12:16:22
Original
1061 people have browsed it

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 />
Copy after login

我把上述xml的信息转存到mysql,在查询的时候发现中间带有空格键的某些值是可以查询的,而某些却查询不到.
比如
SELECT * FROM `dux_region` WHERE `region_name` = 'Aland lslands' 可以查询出来
而手写的'United States'
SELECT * FROM `dux_region` WHERE `region_name` = 'United States' 不能查出数据
但是从XML中复制的 ‘United States’却可以
网上说是中间 空格符 的问题
这个问题如何解决
------解决思路----------------------
$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 />}
Copy after login
United? Arab? Emirates" Code="ARE">
556e69746564c2a041726162c2a0456d6972617465732220436f64653d22415245223e0d
United? Kingdom" Code="GBR">
556e69746564c2a04b696e67646f6d2220436f64653d22474252223e0d
United? States" Code="USA">
556e69746564c2a05374617465732220436f64653d22555341223e0d
United? States? Minor? Outlying? Islands" Code="UMI" />
556e69746564c2a0537461746573c2a04d696e6f72c2a04f75746c79696e67c2a049736c616e64732220436f64653d22554d4922202f3e0d

看到了吧?那可不是空格哟,虽然表现一样

而反过来查
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 />}
Copy after login
就更多了

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!