Skip to main content

Posts

XPath Matching in Unique XML Namespaces (xmlns)

I ran into a problem trying to get my Python script to locate an etree node in an XML document that had declared a namespace for all elements in the document. The trouble I was seeing is that the find and xpath functions weren't returning anything for any of the searches I was doing. Nothing seemed to make sense until I realized that I wasn't including the namespace in the search. The bugger with this is that you have to declare the ns on each and every element in the document! To simplify things a little, i went with code that looked a little like this: The full code: from lxml import etree as ET fp = open("sitemap.xml","r") element = ET.parse(fp) namespace = "{http://www.sitemaps.org/schemas/sitemap/0.9"}" e = element.findall('{0}url'.format(namespace)) for i in e: print i.text

Editing XML/DTDs/XSLT/XPath in Linux

My favorite new tool for editing XML in Linux? Eclipse. That's right. The does-it-all-and-comes-with-batteries-too tool does a great job editing XML, XSLT, xpath, etc. All you need to do is add the plugin for Eclipse Web Tools (available in the standard list of plugins). Just enable the software site and install the latest version! Very simple and very powerful.

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 ...

PyDev and Code Completion

I was struggling with code completion/hinting in PyDev on Eclipse 3.5.2 (default for Ubuntu) and came across this little useful tidbit on the Internet: 'To enable code completion, go to Window > Preferences > Pydev > Editor > Code Completion, and check the 'Use Code Completion?' box, as well as the other boxes for what you want to complete on. It seems to take a second to load, the first time it has to complete something.' Problem solved! I now have my autocomplete settings just the way I want them! Thanks Internet! If I haven't said it lately, you're awesome.

Ubuntu 11.04 Desktop. Who Cares?

I don't mean to be completely cynical, but it seems like Ubuntu's releases have sort of lost their 'umph' over the past few releases. 10.04 seems like the last "big deal" to come from Canonical, and even that's debatable. Some would claim 8.04 or 8.10 as the last big thing. As for 11.04, I don't know if it's the promised break with Gnome as the default desktop, lack of ground breaking improvements, or what, but it just doesn't seem to be getting the clout 8.x, 9.x, and even 10.04 releases had. Personally, I'm done with non-LTS releases unless something EXTREMELY significant comes along. I guess you can tell that the switch to Unity doesn't impress me all that much. Honestly, I just haven't seen the same level of innovation I had grown accustomed to in past releases. I could be wrong, so let's hear your thoughts.

Hey, It's a Post!

Just cracked open the old blog and noticed that I haven't posted since Sept (!) and I wanted to post something, so here it is. I bought a house last month so I've been a bit busy with all of that. In fact, my "me" time that I used to use to play around with all the new technology out there has been significantly reduced. I will say that I have spent a few days playing around with Tomcat6, Spring tc Server, and more than a handful of various .WAR files. I have to say I'm impressed. Incredibly powerful, simple, and useful technologies don't always find their way to the masses, but this is definitely a win. I'm still torn as to whether or not this makes more or less sense than a Python-based solution, but so far, I'm up for further investigation. What do you think? What's your favorite webapp platform and why? What languages do you tend to go to when it's "your program" and not someone else's? And for the million-dollar follow-u...

Ubuntu 10.10: Maverick Meerkat

We're rapidly approaching the release date of the next Ubuntu release: 10/10/2010 (whoa, how's that for an epic release date?). I'm still on the fence about "upgrading" because I like the idea of stability for a while (at least on my work computer). I'll definitely be tossing this on a test machine once it releases. I'll use it to show off the next gen of features if nothing else. For the uninitiated, the features list can be found here . My understanding of this release is that it'll be a playground for many cutting edge features. Stability is definitely not one of the key goals. What are your plans for this release? Production? Playground? Testing? Skip it? Let us know in the comments!