Re: [Tutor] Fwd: find second occurance of string in line

2015-09-08 Thread Peter Otten
Albert-Jan Roskam wrote: >> import lxml.etree >> >> tree = lxml.etree.parse("example.xml") >> print tree.xpath("//objectdata/general/timestamp/text()") > > Nice. I do need to try lxml some time. Is the "text()" part xpath as well? Yes. I think ElementTree supports a subset of XPath. __

Re: [Tutor] Fwd: find second occurance of string in line

2015-09-08 Thread Peter Otten
richard kappler wrote: >> Do you want to find just the second occurence in the *file* or the second > occurence within a given tag in the file (and there could be multiple such > tags)? > > There are multiple objectdata lines in the file and I wish to find the > second occurence of timestamp in e

[Tutor] Fwd: find second occurance of string in line

2015-09-08 Thread richard kappler
> Do you want to find just the second occurence in the *file* or the second occurence within a given tag in the file (and there could be multiple such tags)? There are multiple objectdata lines in the file and I wish to find the second occurence of timestamp in each of those lines. > Is objectdat

Re: [Tutor] find second occurance of string in line

2015-09-08 Thread Alan Gauld
On 08/09/15 17:00, richard kappler wrote: I need to find the index of the second occurance of a string in an xml file for parsing. Do you want to find just the second occurence in the *file* or the second occurence within a given tag in the file (and there could be multiple such tags)? I un

[Tutor] find second occurance of string in line

2015-09-08 Thread richard kappler
I need to find the index of the second occurance of a string in an xml file for parsing. I understand re well enough to do what I want to do on the first instance, but despite many Google searches have yet to find something to get the index of the second instance, because split won't really work on