这是我的代码:
<?php
$dom = new DOMDocument();
$dom->load('http://services.gisgraphy.com/geoloc/search?lat=22.298569900000000000&lng=70.794301799999970000&radius=7000', true);
$dom->save('filename.xml');
?>
我得到这种类型的输出:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<results xmlns="http://gisgraphy.com">
<numFound>1</numFound>
<QTime>67</QTime>
<result>
<distance>1139.81967842778</distance>
<name>Rājkot</name>//
<adm1Code>09</adm1Code>
<adm1Name>State of Gujarāt</adm1Name>
<asciiName>Rajkot</asciiName>
<countryCode>IN</countryCode>
<featureClass>P</featureClass>
<featureCode>PPL</featureCode>
<featureId>1258847</featureId>
<gtopo30>139</gtopo30>
<population>1177362</population>
<timezone>Asia/Kolkata</timezone>
<lat>22.299999237060547</lat>
<lng>70.78333282470703</lng>
<placeType>City</placeType>
<oneWay>false</oneWay>
<length>0.0</length>
<google_map_url>http://maps.google.com/maps?f=q&amp;ie=UTF-8&amp;iwloc=addr&amp;om=1&amp;z=12&amp;q=R%C4%81jkot&amp;ll=22.329999237060548,70.78333282470703</google_map_url>
<yahoo_map_url>http://maps.yahoo.com/broadband?mag=6&amp;mvt=m&amp;lon=70.78333282470703&amp;lat=22.299999237060547</yahoo_map_url>
<country_flag_url>/images/flags/IN.png</country_flag_url>
</result>
</results>
在上面的 XML 文件中,我想将name
节点值中的特殊字符转换为简单字符,例如Rājkot
包含ā
我想转换为简单字符的特殊a
字符。