0

I have just started experimenting with Google's GO (Golang) language, and have run into a problem that I would like to solve efficiently. So I would like to extract some data from an XML file, that is available online (I get it as the response of a polling session), but I don't know how to get started. Should I download the source code of the page, store it locally and extract the data that way or is there a possibility to extract the data without downloading the whole thing? Thank you!

<?xml version="1.0" encoding="utf-8"?>

1 Answer 1

2

Since its available online you can use net/http client to retrieve the xml. Then you can use encoding/xml package and convert the response body to struct object, it has xml.Unmarshal method to convert xml string to struct - hence you should write the struct first.

net/http example available

encoding/xml example

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.