简体   繁体   English

XML格式错误,但我不知道为什么

[英]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&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=51.75,-1.25&amp;sll=52.7115,-2.0006&amp;sspn=0.07831,0.264187&amp;ie=UTF8&amp;ll=51.75,-1.25&amp;spn=0.048204,0.132093&amp;z=14&amp;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&amp;sensor=false&amp;zoom=13&amp;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.

相关问题 问题无法解析XML,不知道为什么我收到此错误? - Problem Failed to parse XML, don't know why i'm getting this error? 使用 Node.js 我验证了 xml 模式的 xml 模式,但它失败了。 我不知道为什么 - Using Node.js I validated the xml schema for xml schemas and it failed. I don't know why 我不知道如何在Android上处理这种xml结构 - I don't know how to deal with this kind of xml structure on android 有时会抛出FileNotFoundException,我不知道为什么 - FileNotFoundException is being thrown sometimes and i don't know why 不知道为什么XML Schema格式不正确? - Don't know why XML Schema isn't well-formed? XML解析器不知道空格长度 - XML parser don't know whitespace length 使用XStream读取XML进行对象处理时,如果我不知道XML将具有多少个字段怎么办? - While using XStream to read XML to object, what if I don't know how many fields the XML will have? 解析XML,我没有错误,我不知道怎么了? - Parsing XML, i have no errors, i don't know whats wrong? 我不知道可以在哪里放置C#XML设置文件 - i don't know where i can put C# XML Setting File 如果我事先不知道Java对象,如何将XML转换为Java对象? - How can I convert XML to Java object if I don't know the Java object in advance?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM