Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #88779
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Subject | Re: Help with ElementTree |
| Date | 2015-04-10 14:02 +0200 |
| Organization | None |
| References | <CACwCsY4-3_7RBtx2LTLZ6pEAk-qW31XxeZz4aFVCmyK6f4Tong@mail.gmail.com> <mg6h07$uh$1@ger.gmane.org> <CACwCsY63BwubfhmNydzsu8Pg5qSKt6MJ_-N44hh0+yBSmZM7Sg@mail.gmail.com> <CACwCsY5vfpqGnYyCLi-7UVGNTm5VZbGddDPpW6UX+=cygUfUng@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.204.1428667359.12925.python-list@python.org> (permalink) |
Larry Martell wrote:
> root.find("Doc/Node[@Name='SystemConfig']/Node[@Name='Environment']/"
> "Parameter[@Name='ToolName']/Value/Current").text
> So I tested this on a machine running 2.7, but then when I deployed it
> to my client's machine it did not work. Turns out they're running 2.6
> which I find does not support searching for attributes using the
> [@attribute] syntax. They do not want to upgrade, so I have to find a
> way to do this without using that. :-(
A quick and dirty approach (untested!):
Add the ElementPath.py from 2.7 to your project (as myelementpath.py, say)
and monkey-patch ElementTree:
import xml.etree.ElementTree
import myelementpath
xml.etree.ElementTree.ElementPath = myelementpath
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Help with ElementTree Peter Otten <__peter__@web.de> - 2015-04-10 14:02 +0200
csiph-web