Newbie: I have a big xml file, the content is much nested tags and what I need to do is adding a field in a very nested tag in this file. One “not elegant” way is to make thousands of structs to parse the file. Do you guys have a simple solution for a task like that.

This page summarizes the projects mentioned and recommended in the original post on /r/golang

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • zek

    Generate a Go struct from XML.

  • Here's the local version: https://github.com/miku/zek/ Alternatively, https://github.com/gnewton/chidley does the same thing.

  • mxj

    Decode / encode XML to/from map[string]interface{} (or JSON); extract values with dot-notation paths and wildcards. Replaces x2j and j2x packages.

  • It generates Go structs from XML files. Compared to projects like https://github.com/clbanning/mxj, it generates much better Go code and you can feed it multiple example XML files.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • chidley

    Convert XML to Go structs / XML to JSON

  • Here's the local version: https://github.com/miku/zek/ Alternatively, https://github.com/gnewton/chidley does the same thing.

  • xmlquery

    xmlquery is Golang XPath package for XML query.

  • If "big" isn't actually that big compared to the RAM of the system you are running on, one option is to use an XPath library like xmlquery, which will allow you to iterate over the document using XPath expressions. You can make changes to it inline, then re-serialize it.

  • go-xmlstruct

    Generate Go structs from multiple XML documents.

  • Check out https://github.com/twpayne/go-xmlstruct.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts