Skip to main content

Manipulating XML Using Python

I work with XML-related content on a day-to-day basis at work. I come from a .NET background and have written dozens of applications that leverage DOM when manipulating XML. Recently, I've started broadening my horizons to include more languages. I've written a few applications in Python now to do similar tasks as my .NET applications and there's one area that I always find lacking: XML manipulation with eTree. Perhaps I'm mistaken, but it appears from community pages that eTree is the defacto standard in Python for manipulating XML. Sure, it does *most* things correctly, but every once in a while, I can't help but stop and think, this was a whole lot easier with such and such method in .NET or, why does etree.xpath() work when etree.find() doesn't? Why are there two ways to do essentially the same thing in the same class library anyway?

One area that eTree really lacks cohesive support is mixed type XML (Some Text some more text even more text.). Dealing with tails and heads in this sort of situation is a nightmare but completely normal in the XML I work with.

Maybe I'm coming about this the wrong way. Maybe there's a better option out there I haven't considered yet? Maybe I'm just not used to seeing DOM in a Python-esque way. What do you think?

Comments

Popular posts from this blog

Black Cursors on Win7/2008 R2 Using rdesktop for Ubuntu 10.04

I recently setup a Win 2008 R2 VM and proceeded to remote connect to it from Ubuntu 10.04. Everything worked perfectly except the mouse cursors were black (and some were corrupt). Solution? Use a newer version of rdesktop that doesn't ship with Ubuntu. There is a handy PPA that can be added using the following command: sudo apt-add-repository ppa:ricolai/ppa sudo apt-get update sudo apt-get install rdesktop [UPDATE] It appears ricolai may have removed the package from his PPA. To remedy the situation, I've uploaded the working binaries for x64. Sorry, I don't have the x86 any longer. More information on the bug can be found here: https://bugs.launchpad.net/ubuntu/+source/rdesktop/+bug/385974?comments=all

Long Time, No Write

It's been a loooong time since I last wrote. The past several years have seen a huge shift in my career and technical objectives. I've gone from working almost exclusively on code to selling software as a technical sales engineer to now managing a team of technical gurus doing sales worldwide. As a result, my time for tinkering has slowed considerably. I do want to update everyone by saying that I am now back to Linux after many years stuck in a Windows world for work. My current employer is focused on open source technology and as such encourages us to use Linux and other open source tools in any way we can. I am now the proud owner of a Dell Laptop that has dual-boot setup for Windows and Ubuntu 18.04. I'll try to write up a post here in the next bit about my experiences so far, but my quick and dirty summary is that you should definitely give it a shot. There are a few hiccups to overcome, but, for the most part, it's been really nice transitioning back. Until ...