Created
November 7, 2017 09:11
-
-
Save Ynn/e6539960a8f54e38938d6ada7c56a4f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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