Follow

Help for an XML novice: I have a set of individual XML files/records. I want to extract the value of two or three elements in each record and export those to, e.g. a CSV.

Can I do this with XPath?

@The_BFOOL XPath + XSLT can do this, but XPath alone just points at the elements.

@The_BFOOL Personally I'd use Python with an XML parser. As @anj says, XSLT can do it. You'd need the xpaths for either. If you're interested in the Python path, I can give you some code snippets later today which should get you underway.

@platypus @The_BFOOL if you’re up for doing it in Python it also makes it a bit easier to manage the CSV. XSLT can output plain text but it’s clunky.

@anj @platypus something in Python would actually be perfect - in context, we already have a Python script (written by former student) that takes software objects based on an input ID and creates XML records for EaaSI, including a newly-generated UUID.

The UUID is what actually shows up in our platform, so I want that ID->UUID pairing to match precisely what I'm looking at. Incorporating a new snippet into the existing script would be way more efficient than adding another step!

Sign in to participate in the conversation
digipres.club

digipres.club is a space for folks interested in productive conversations about, well, digital preservation! If you enjoy talking about how to do memory work with computers, or even with cardboard boxes of old photos, you belong with us on digipres.club. Many of us are/were Twitter users looking for an inclusive and community supported approach to social media. If any of these things sound good to you, consider joining us now.