我的XML有点生疏,但我正在尝试用XML创建一个基于Web的本地天气api。但是它没有完成,但我在测试时遇到了错误,这是
第16行第3行的错误:AttValue:“或'预期。
我的代码:
<local_weather>
<local_counties>
<county id = 1>
<name> Suffolk </name>
<location>
api.openweathermap.org/data/2.5/weather?q=Ipswich,uk&APPID=6ce0e1da2bbce97fe9e735c3a2009c71
</location>
<name> Norfolk </name>
<location>
api.openweathermap.org/data/2.5/weather?q=Norwich,uk&APPID=da4be448d33cb1b0d8b5bdaa4daca4f7
</location>
<name> Essex </name>
<location>
api.openweathermap.org/data/2.5/weather?q=Chelmsford,uk&APPID&APPID=9fa167ffbd810a6cdbf0fe73597d92fe
</location>
<name> Cambridgeshire </name>
<location>
api.openweathermap.org/data/2.5/weather?q=Peterborough,uk&APPID&APPID=2dcefd34930d723d95c0c3d910f90c3d
</location>
</local_counties>
</local_weather>
答案 0 :(得分:3)
要使XML well-formed ,需要进行三次更正:
<county id= 1 >
更改为<county id="1">
。 county
添加结束标记。&
替换为&
。以下是您的XML已更正为格式良好:
<local_weather>
<local_counties>
<county id ="1">
<name> Suffolk </name>
<location>
api.openweathermap.org/data/2.5/weather?q=Ipswich,uk&APPID=6ce0e1da2bbce97fe9e735c3a2009c71
</location>
<name> Norfolk </name>
<location>
api.openweathermap.org/data/2.5/weather?q=Norwich,uk&APPID=da4be448d33cb1b0d8b5bdaa4daca4f7
</location>
<name> Essex </name>
<location>
api.openweathermap.org/data/2.5/weather?q=Chelmsford,uk&APPID&APPID=9fa167ffbd810a6cdbf0fe73597d92fe
</location>
<name> Cambridgeshire </name>
<location>
api.openweathermap.org/data/2.5/weather?q=Peterborough,uk&APPID&APPID=2dcefd34930d723d95c0c3d910f90c3d
</location>
</county>
</local_counties>
</local_weather>
答案 1 :(得分:1)
您需要使用单引号或双引号包装id
属性的值。
<county id="1">
答案 2 :(得分:0)
我想你想写:
<country id = "1">
(注意引号。)