Skip to content

Instantly share code, notes, and snippets.

@Ynn
Created November 7, 2017 09:11
Show Gist options
  • Save Ynn/e6539960a8f54e38938d6ada7c56a4f7 to your computer and use it in GitHub Desktop.
Save Ynn/e6539960a8f54e38938d6ada7c56a4f7 to your computer and use it in GitHub Desktop.
package main
import "fmt"
import "encoding/xml"
import "net/http"
import "io/ioutil"
type ObixReal struct {
Value float32 `xml:"val,attr"`
}
func main() {
resp, err := http.Get("http://example.com/obix/config/Drivers/ModbusAsyncNetwork/LEM_salle_925/points/Energie_Active_Prises_925/out/")
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
v := ObixReal{}
err = xml.Unmarshal(body, &v)
if err != nil {
return
}
fmt.Printf("%f \n", v.Value)
fmt.Printf("%q \n", v)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment