XML : Error unmarshalling GML with golang encoding/xml

I am trying to unmarshal some XML, actually Geography Markup Language (GML)

I have an example at http://play.golang.org/p/qS6GjCOtHF

Two problems, the first:

error reading xml main.FeatureCollection field "LowerCorner" with tag "boundedBy>Envelope>lowerCorner" conflicts with field "Envelope" with tag "boundedBy>Envelope"

I have no idea how to fix that. I commented those out and get the GML to unmarshal without errors but then there are no Features in the FeatureCollection.

Any clues?

An example of the GML is:

  <?xml version="1.0" encoding="UTF-8"?>  <gml:FeatureCollection xmlns:gml="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:fme="http://www.safe.com/gml/fme" xsi:schemaLocation="http://www.safe.com/gml/fme tblMainGML.xsd">  <gml:boundedBy>  <gml:Envelope srsName="EPSG:3112" srsDimension="2">  <gml:lowerCorner>45.2921142578125 -80.2166748046875</gml:lowerCorner>  <gml:upperCorner>169.000122070313 -9.14251708984375</gml:upperCorner>  </gml:Envelope>  </gml:boundedBy>  <gml:featureMember>  <fme:GML gml:id="id5255fa48-42b3-43d1-9e0d-b2ba8b57a936">  <fme:OBJECTID>1</fme:OBJECTID>  <fme:RECORD_ID>QLD48234</fme:RECORD_ID>  <fme:NAME>HATCHMAN POINT</fme:NAME>  <fme:FEAT_CODE>PT</fme:FEAT_CODE>  <fme:CGDN>N</fme:CGDN>  <fme:AUTHORITY_ID>QLD</fme:AUTHORITY_ID>  <fme:CONCISE_GAZ>N</fme:CONCISE_GAZ>  <fme:LATITUDE>-12.58361</fme:LATITUDE>  <fme:lat_degrees>-12</fme:lat_degrees>  <fme:lat_minutes>35</fme:lat_minutes>  <fme:lat_seconds>0</fme:lat_seconds>  <fme:LONGITUDE>141.62583</fme:LONGITUDE>  <fme:long_degrees>141</fme:long_degrees>  <fme:long_minutes>37</fme:long_minutes>  <fme:long_seconds>32</fme:long_seconds>  <fme:STATE_ID>QLD</fme:STATE_ID>  <fme:STATUS>U</fme:STATUS>  <fme:VARIANT_NAME/>  <fme:MAP_100K>7272</fme:MAP_100K>  <fme:Place_ID>45880</fme:Place_ID>  <gml:pointProperty>  <gml:Point srsName="EPSG:3112" srsDimension="2">  <gml:pos>141.625915527344 -12.5836181640625</gml:pos>  </gml:Point>  </gml:pointProperty>  </fme:GML>  </gml:featureMember>  </gml:FeatureCollection>  </xml>    

My structs

  type FeatureCollection struct {      Xsi            string   `xml:"xsi,attr"`      Fme            string   `xml:"fme,attr"`      Gml            string   `xml:"gml,attr"`      Xlink          string   `xml:"xlink,attr"`      LowerCorner    string   `xml:"boundedBy>Envelope>lowerCorner"`      UpperCorner    string   `xml:"boundedBy>Envelope>upperCorner"`      Envelope       Envelope `xml:"boundedBy>Envelope"`      SchemaLocation string   `xml:"schemaLocation,attr"`      Features       []Feature  }    type Feature struct {      PlaceID     string `xml:"featureMember>GML>Place_ID"`      StateID     string `xml:"featureMember>GML>STATE_ID"`      Postcode    string `xml:"featureMember>GML>POSTCODE"`      CGDN        string `xml:"featureMember>GML>CGDN"`      Map100K     string `xml:"featureMember>GML>MAP_100K"`  ETC...  }    

No comments:

Post a Comment