In general, you cannot convert xml to json. They have incompatible models. XML elements are ordered similar to a JSON array, but in many cases you want to map XML elements to JSON objects, which are unordered name-value collections. Also, there is no JSON equivalent of an XML attribute.
If you want to work with XML, either use xml marshaling, or find a third-party DOM library. On Tue, Apr 23, 2024 at 10:29 AM Don Caldwell <dfw...@gmail.com> wrote: > > Disclaimer - I am very new to golang. > I puzzled about this for a few days. After some struggle, I got a little > program working that parses > arbitrary xml into a structure that json can understand. You can find it here: > https://github.com/dfwcnj/gxmldecode > > On Thursday, October 7, 2021 at 10:06:30 AM UTC-4 RS wrote: >> >> What is the best approach to convert xml to json? >> However I need above all to parse a very complex xml to see if related >> properties are existing. >> I thought maybe converting it to Json maybe make it easier. >> >> > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/90c0dd22-2d81-4393-b534-651a2376f386n%40googlegroups.com. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAMV2RqowOgbOnmGxsWegOuJ-_crQcNhsjj1Gxk3pAXhBmtNK5Q%40mail.gmail.com.