[lxml-dev] Patch for xpathgrep.py
Thomas Schraitle
tom_schr at web.de
Mon Jun 9 15:42:05 CEST 2008
Hi Stefan,
> [...]
> > To improve it a bit, I've created a humble patch against xpathgrep.py.
> > I've
> > looked at it and I missed a namespace option. Well, here it is. See the
> > attached patch. Hope it's ok, feel free to adapt it to your needs.
>
> I considered using ETXPath() instead of plain XPath() for that script, so
> that you can say "//{ns}stuff". But I think your patch makes sense as well
> and may mean less typing/c&p on the cmd line. I'll enable both then.
Ahh, I forgot about the Clark notation. Good to know, thanks! I'm so get used
to the prefix notation.
By the way, I think there is a small error in my patch: The variable namespaces
isn't correctly initialized. There should be a "parser.set_defaults(namespaces=[])"
before the "parser.add_option("-N", "--ns", ...)" line.
To spread the word about lxml and xpathgrep.py: I've wrote a small article here:
http://lizards.opensuse.org/2008/06/09/query-your-xml-with-xpathgreppy/
:-)
Thanks,
Tom
More information about the lxml-dev
mailing list