Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML error: AttValue: " or ' expected

Tags:

xml

My XML is a bit rusty, but I'm trying to create a local weather web-based api in XML. It is not finished however, but I have run into an error whilst testing it out, which is

error on line 3 at column 16: AttValue: " or ' expected.

My code:

<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>
like image 606
Sam Avatar asked Mar 12 '23 02:03

Sam


2 Answers

There are three corrections necessary to make your XML well-formed:

  1. Change <county id= 1 > to <county id="1">.
  2. Add an end tag for county.
  3. Replace & with &amp;.

Here is your XML corrected to be well-formed:

<local_weather>
    <local_counties>
        <county id ="1">
            <name> Suffolk </name>
            <location>
                api.openweathermap.org/data/2.5/weather?q=Ipswich,uk&amp;APPID=6ce0e1da2bbce97fe9e735c3a2009c71  
            </location>
            <name> Norfolk </name>
            <location>
                api.openweathermap.org/data/2.5/weather?q=Norwich,uk&amp;APPID=da4be448d33cb1b0d8b5bdaa4daca4f7
            </location>
            <name> Essex </name>
            <location>
                api.openweathermap.org/data/2.5/weather?q=Chelmsford,uk&amp;APPID&amp;APPID=9fa167ffbd810a6cdbf0fe73597d92fe
            </location>
            <name> Cambridgeshire </name>
            <location>
                api.openweathermap.org/data/2.5/weather?q=Peterborough,uk&amp;APPID&amp;APPID=2dcefd34930d723d95c0c3d910f90c3d
            </location>
        </county>
  </local_counties>
</local_weather>
like image 140
kjhughes Avatar answered Mar 16 '23 00:03

kjhughes


You need to wrap the value of your id attribute with a single or double quote.

<county id="1">
like image 35
LazerSharks Avatar answered Mar 16 '23 00:03

LazerSharks