0

I have a .txt File with lots of XML-Files in it.

So lets say: content.txt is my file, and there are 40++ XML-"Files" in it. (No "real" files, of course, but tags with <xml>....</xml><xml>...</xml> and so on).

Now i want to create a parser in Python which reads the text-file, and writes every <xml>...</xml> in a file. The name should be a Tag-Data inside each <xml>....</xml>.

What's the best solution for my problem?

I've read a lot about XML parsers, but nobody explains how to read AND write at the same time.

bereal
  • 32,519
  • 6
  • 58
  • 104
ohboy21
  • 4,259
  • 8
  • 38
  • 66
  • 1
    Sorry, I can't understand. You know how to read, and you know how to write, what prevents you from reading and then writing? The only problem to solve here, is how to split a sequence of xml-documents into a sequence of those from a single file, since XML parsers allow only one document. – bereal Jan 30 '13 at 09:35
  • 1
    And the latter problem is partially solved here http://stackoverflow.com/a/4024838/770830 by wrapping the text document into a single parent tag... Unless you have some `` declaration. – bereal Jan 30 '13 at 09:38

0 Answers0