[英]XML malformed but i don't know why
I have the following XML: 我有以下XML:
<?xml version="1.0" encoding="ISO-8859-1"?>
<results>
<ip>195.72.186.157</ip>
<country>UNITED KINGDOM (UK)</country>
<city>Oxford</city>
<latitude>51.75</latitude>
<longitude>-1.25</longitude>
<staticmap>http://maps.google.com/maps/api/staticmap?center=51.75,-1.25&sensor=false&zoom=13&size=500x300</staticmap>
<dynamicmap>http://maps.google.co.uk/maps?f=q&source=s_q&hl=en&geocode=&q=51.75,-1.25&sll=52.7115,-2.0006&sspn=0.07831,0.264187&ie=UTF8&ll=51.75,-1.25&spn=0.048204,0.132093&z=14&output=embed</dynamicmap>
</results>
The problem is it is coming up as malformed when I validate it. 问题是当我验证它时它显示为格式错误。 The character in question that it doesn't like is an equals sign.
它不喜欢的相关字符是等号。 What is its problem with it?
它有什么问题? I validated it here:
我在这里验证了它:
http://www.w3schools.com/dom/dom_validate.asp http://www.w3schools.com/dom/dom_validate.asp
You're missing an amp; 您缺少一个放大器; next to the sensor parameter in the staticmap element.
在staticmap元素中的sensor参数旁边。 In fact, you need to encode all ampersands in that element value.
实际上,您需要在该元素值中对所有“&”号进行编码。
Your need to encode your ampersands in the Google Maps URL, ie 您需要在Google Maps URL中对与号进行编码,即
<staticmap>http://maps.google.com/maps/api/staticmap?center=51.75,-1.25&sensor=false&zoom=13&size=500x300</staticmap>
You did it for the <dynamicmap>
, but not the <staticmap>
您是为
<dynamicmap>
,但不是为<staticmap>
those charackters are reserved in xml. 这些字符保留在xml中。 you can either replace them with their charcode equivalents (using &#NNN;) or wrap the urls in a CDATA section
您可以用等效的字符代码替换它们(使用&#NNN;),也可以将网址包装在CDATA部分中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.