I am trying to parse a large text file. The text file is not actually a XML file. The tags which look like this:

```
<tag1>
<tagsomedata> text1 </tagsomedata>
<text> text some pattern1 </text>
</tag1>
<tag1>
<tagsomedata> text2 </tagsomedata>
<text> text some pattern2 </text>
</tag1>

```

and so on.. 

I need output in the form :

text1 pattern1

text2 pattern2

I used BeautifulSoup and it worked for a shorter file well. I was reading the file as filetext=open(filename).read(). For larger original file it gave segmentation fault 11 error.

I can not read my file in some fixed sizes as the tags can get split. I need to read the file tagwise. In above example I will iterate through "tag1" and get required values of every subtag.

I also tried xml.etree.ElementTree but it requires well parsed XML. I tried manually changing some obvious unwanted tags from XML file but it still gave error "mismatched tag". I have such 100+ files and I can not manually change each file.

Please let me know what can be done in this case?