Oops, I didn't look carefully at the json output of my little program. It does sometimes emit arrays. For example:
go build xmlparse.go ./xmlparse -url 'https://news.google.com/atom' This produces what, for some part, represents acceptable json. The exceptions are the atom entries that would still require, I think, another pass to fix up the go structure unless someone applies a priori knowledge of the xml structure when building it. D D D On Tue, Apr 23, 2024 at 1:18 PM Don Caldwell <dfw...@gmail.com> wrote: > I agree. The link that I sent demonstrates one very simple way. Mapping > XML with repetitive tag sets to JSON arrays, though, would take a bit of > work meaning, I think, at least two passes. > > D > > On Tue, Apr 23, 2024, 13:04 robert engels <reng...@ix.netcom.com> wrote: > >> I don’t think that is true. There are multiple ways to model XML into >> json. >> >> See this http://badgerfish.ning.com for one of them. >> >> On Apr 23, 2024, at 11:43 AM, burak serdar <bser...@computer.org> wrote: >> >> 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 >> . >> >> >> -- 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/CAGw7KvrJJMQ6DOVC2vhgVru9rDc%3D--fOWpy9i6iCKaH-HeMuUA%40mail.gmail.com.