• corroded@lemmy.world
    link
    fedilink
    arrow-up
    25
    ·
    4 months ago

    I’m okay with the “human-readability,” but I’ve never been happy with the “machine-readibility” of XML. Usually I just want to pull a few values from an API return, yet every XML library assumes I want the entire file in a data structure that I can iterate through. It’s a waste of resources and a pain in the ass.

    Even though it’s not the “right” way, most of the time I just use regex to grab whatever exists between an opening and closing tag. If I’m saving/loading data from my own software, I just use a serialization library.

    • Chris@feddit.uk
      link
      fedilink
      English
      arrow-up
      8
      ·
      4 months ago

      Yep, it’s a PITA to parse and get the values you want. Much prefer JSON. Recently when I needed to parse XML I ran it through an XML to JSON library. Much easier!

      If you need to parse XML just for RSS though, it isn’t so bad as there are RSS specific libraries which take most of the pain away.

      • corroded@lemmy.world
        link
        fedilink
        arrow-up
        4
        ·
        4 months ago

        I appreciate the suggestion, but that looks like a Java library. Interpreted languages make me feel dirty. Java makes me feel even dirtier. If it’s not C, C++, or ASM, is it really worth using?

        • MagicShel@programming.dev
          link
          fedilink
          arrow-up
          2
          ·
          4 months ago

          Idk. Been doing it for nearly 20 years and before that I was doing IBM’s take on VBScript for another 10. So I have my own perspective there. I’ve only ever had to parse massive xmls when doing web apps, and for web backends I really only like Java and NodeJS.

          But everyone is entitled to their own take. I would imagine there is a streaming parser in other languages as well.