views:

60

answers:

2

I'm interested in both xpath matching and full document comparisons:

assert_that(mydoc, hasTextAtXPath('/foo/bar', 'text'))

assert_that(mydoc, matchesStructurally('<some_xml/>'))

Does any matcher library exist for this? If not, what is the best place to start with for this type of comparison, so that I can write one of my own?

A: 

lxml has XPath matching: http://codespeak.net/lxml/

Antoine P.
A: 

There is a Python version of Hamcrest. It does not currently provide XML matchers. I'd be happy to work on some if you define what you need.

Jon Reid
I'm using said version. What I'm looking for is a matcher that can -- using some basic XML Canonicalization rules analogous to the ones used for WS-Security over in web-services-land -- check that an XML node has identical structure to the matched item.Also, the ability to check XPath results would be nice, as exemplified in the upper line of code.
Chris R