Comparing XML files ignoring order of attributes and child elements

October 6th, 2014

I need to diff some XML files.

For these particular XML files, order is not important. The XML is being used to contain a set of things, not a list – the order of the elements has no significance. Similarly, the order of the attributes within each element isn’t significant.

For example, for my purposes, these two XML files are equivalent:

<myroot>
    <mychild id="123">
        <fruit>apple</fruit>
        <test hello="world" brackets="angled" question="answers"/>
        <comment>This is a comment</comment>
    </mychild>
    <mychild id="456">
        <fruit>banana</fruit>
    </mychild>
    <mychild id="789">
        <fruit>orange</fruit>
        <test brackets="round" hello="greeting">
            <number>111</number>
        </test>
        <dates>
              <modified>123</modified>
              <created>253</created>
              <accessed>44</accessed>
        </dates>
    </mychild>
</myroot>
<myroot>
    <mychild id="789">
        <fruit>orange</fruit>
        <test hello="greeting" brackets="round">
            <number>111</number>
        </test>
        <dates>
              <accessed>44</accessed>    
              <modified>123</modified>
              <created>253</created>
        </dates>
    </mychild>
    <mychild id="123">
        <test question="answers" hello="world" brackets="angled"/>
        <comment>This is a comment</comment>
        <fruit>apple</fruit>
    </mychild>
    <mychild id="456">
        <fruit>banana</fruit>
    </mychild>
</myroot>

I needed to compare some large XML files, which have big differences in the order of elements, and I couldn’t find a tool that would do the job. So I wrote a bit of Python to do it for me.

Read the rest of this entry »

Kids should learn to code

September 27th, 2014

Does a five-year-old need to learn how to code?

A couple of weeks ago I was interviewed by the BBC. In a fairly long phone call, I either rambled inanely or provided detailed and nuanced answers in context. That depends on your point of view.

Either way, obviously not a lot of it could make it into their story, as they really only needed a few quotes. So I thought I’d put more of what I said here.

The background for the story was the changes to the UK school curriculum which means that all kids are being taught to code. And the basic premise for the piece was that as we’re “entering an era when computers are actually beginning to teach themselves” that this is unnecessary and that coding itself is becoming an outdated skill.

Read the rest of this entry »

Holiday by numbers

August 6th, 2014

We’re back from holiday! We went up to Glasgow to watch some of the Commonwealth Games, and used it as a chance to have a road trip and see a few more places in the UK on the way.


Photos we took at the Games on flickr

I want to describe our last two weeks, so decided to do it with statistics and photos!

Read the rest of this entry »

Talking about IBM Watson (again)

July 17th, 2014

As I mentioned in May, I was lucky to be able to go to Thinking Digital this year and talk about what we’re doing with Watson.

I’ve just noticed that they’ve made a video of my talk available. I haven’t dared watch it (does anyone like watching videos of themselves?), but I figured I should share it anyway!

Using Node.js to create a REST API around a SQL database

June 15th, 2014

A few code snippets for how you can quickly stand up a SQL database, and provide a REST API for DB read/writes

I was helping out a team at a hackday hosted at Hursley last week. One of the things they wanted for their hack was a SQL database to put sensor data in, which they could access via a REST API. And they wanted it in node.js.

I’d never used Node before, so I used this as a chance to give myself a first crash-course.

I’m not saying this is the way to do this in Node, as it’s the result of my first hour’s tinkering. But it worked, and I mostly wanted to share how quick and easy it was.

Read the rest of this entry »

Thinking Digital 2014

May 24th, 2014

This week I went up to Newcastle for Thinking Digital.

It was the seventh Thinking Digital, but my first.

I’d seen a bunch of references to it being the UK’s answer to TED, the tickets aren’t cheap, videos from previous years look slick and professional, it’s held in The Sage which is a hugely impressive venue, they manage to get a great line-up of speakers, and the logistics in the run-up to the event were more organised than any event I’ve been to before.

So… I was expecting a cool and geeky, if faceless, serious, formal, and intimidating event.

I’d read it completely wrong. It’s absolutely a professionally run event. And there was no shortage of cool geekiness. But, more than that, the organizer, Herb Kim, has created a real sense of community in it. There’s a feeling of almost familial warmth amongst attendees who come year after year after year.

Read the rest of this entry »

How children learn to do sums in primary school

May 11th, 2014

This is a write-up of the presentation that Grace gave at Barcamp Bournemouth this weekend. I’ve written about the reaction she got already, but I thought her presentation was interesting enough that it’s worth sharing here. 

The idea behind her talk was that the way maths is taught in schools today is different to the way it was done when I went to school.

Put another way, her basic premise was “when Dad helps me with my homework, he gets it all wrong”. ;-)

Read the rest of this entry »

Taking a kid to a barcamp… again

May 10th, 2014

Last year, Grace tagged along with me to Barcamp Berkshire. She gave a talk, and it went pretty well.

I guess she must’ve enjoyed it, because today she came along with me to Barcamp Bournemouth.

I’ll write a post about what she talked about later, as it was actually pretty interesting. First, I want to get the shameless proud dad post out of the way. :-)

Read the rest of this entry »