Page 1 of 1

XML is not well-formed

Posted: Wed Sep 21, 2011 5:08 am
by alexmilowski
I've just setup a weather station with Ambient Weather's WeatherHub2 and the XML returned by the device is *NOT* well-formed. I make this request:

http://.../meteolog.cgi?type=xml&mode=data

and I get:


<logger>
<RAIN date=20110921030058 id=rain0 rate=0.0 total=2.1 delta=0.0>
<TH date=20110921030058 id=th0 temp=13.9 hum=88 dew=11.9>
<THB date=20110921030058 id=thb0 temp=25.4 hum=58 dew=16.5 press=996.8 seapress=1012.9 fc=-1>
<WIND date=20110921030058 id=wind0 dir=315 gust=0.0 wind=0.0 chill=13.9>
</logger>

and should be at least:

<logger>
<RAIN date="20110921030058" id="rain0" rate="0.0" total="2.1" delta="0.0">
<TH date="20110921030058" id="th0" temp="13.9" hum="88" dew="11.9">
<THB date="20110921030058" id="thb0" temp="25.4" hum="58" dew="16.5" press="996.8" seapress="1012.9" fc="-1">
<WIND date="20110921030058" id="wind0" dir="315" gust="0.0" wind="0.0" chill="13.9">
</logger>

I do fail to see why the element names 'RAIN', 'TH', etc. are capitalized when every else is not. That doesn't "hurt" my application but the lack of quotes for attribute values means I can never parse the returned data.

Re: XML is not well-formed

Posted: Wed Sep 21, 2011 3:42 pm
by rovinj
Add quotes=1 at the end, example: http://.../meteolog.cgi?type=xml&mode=data&quotes=1

Re: XML is not well-formed

Posted: Wed Sep 21, 2011 7:37 pm
by admin
The "old" format is the only one that Weather Display can handle. Therefore, the quotes toggle was introduced.