Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #48845
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.008 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'output': 0.05; 'subject:file': 0.07; 'string': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:string': 0.09; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'subject:XML': 0.16; 'elements': 0.16; '(but': 0.19; 'appears': 0.22; 'header:User-Agent:1': 0.23; 'parse': 0.24; 'looks': 0.24; 'header:X-Complaints-To:1': 0.27; 'xml': 0.29; 'dom': 0.31; 'writes:': 0.31; 'subject:all': 0.32; '(e.g.': 0.33; 'could': 0.34; 'there': 0.35; 'leads': 0.36; 'charset:us-ascii': 0.36; 'jason': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'times': 0.62; 'received:217': 0.63; 'high': 0.63; 'such': 0.63; 'provide': 0.64; 'more': 0.64; 'approaches': 0.68; 'elementary': 0.84; 'visitor': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | dieter <dieter@handshake.de> |
| Subject | Re: Finding all instances of a string in an XML file |
| Date | Fri, 21 Jun 2013 08:17:24 +0200 |
| References | <CANy1k1igA3PLR-Pgy9w4T1pbn7d2tK9=6tNpnett6iTjACDs7w@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| X-Gmane-NNTP-Posting-Host | pd9e0b661.dip0.t-ipconnect.de |
| User-Agent | Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.22 (linux) |
| Cancel-Lock | sha1:+Seg+b+3Pw36WEOkM4v34ICKHJ8= |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3653.1371795459.3114.python-list@python.org> (permalink) |
| Lines | 30 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1371795459 news.xs4all.nl 15988 [2001:888:2000:d::a6]:40661 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:48845 |
Show key headers only | View raw
Jason Friedman <jsf80238@gmail.com> writes: > I have XML which looks like: > > <?xml version="1.0" encoding="UTF-8"?> > <!DOCTYPE KMART SYSTEM "my.dtd"> > <LEVEL_1> > <LEVEL_2 ATTR="hello"> > <ATTRIBUTE NAME="Property X" VALUE ="2"/> > </LEVEL_2> > <LEVEL_2 ATTR="goodbye"> > <ATTRIBUTE NAME="Property Y" VALUE ="NULL"/> > <LEVEL_3 ATTR="aloha"> > <ATTRIBUTE NAME="Property X" VALUE ="3"/> > </LEVEL_3> > <ATTRIBUTE NAME="Property Z" VALUE ="welcome"/> > </LEVEL_2> > </LEVEL_1> > > The "Property X" string appears twice times and I want to output the "path" > that leads to all such appearances. You could use "lxml" and its "xpath" support. This is a high end approach: you would use a powerful (and big) infrastructure (but one which could also be of use for other XML applications). There are more elementary approaches as well (e.g. parse the XML into a DOM and provide your own visitor to find the elements you are interested in).
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Finding all instances of a string in an XML file dieter <dieter@handshake.de> - 2013-06-21 08:17 +0200
csiph-web