1 Reply Latest reply: Jun 21, 2010 4:55 PM by 390020 RSS

    Python Programming help please

    779796
      Hi there,

      I got this txt file with following contents:

      <GLOSSARY>
      <INFO>
      <NAME>My Glossary</NAME>
      <INTRO>stuff</INTRO>

      The above text is saved in test.txt file.

      I need to write a python script that would load the above file as list of strings. I then need display only the text from <Name> to </Name> in python.

      If anybody can help me please with the code. I've tried searching a lot but haven't found anything.

      Thank You
        • 1. Re: Python Programming help please
          390020
          What you call a text file, it looks to me like a xml file :)
          There are plenty of useful resources in the web to help you out with this kind of common situation. One of the easiest explanations out there is Dive into Python by Mark Pilgrim: http://diveintopython.org/xml_processing/
          ElementTree is part of the standard lib now so you can take full advantage of it. Please start reading from here:
          http://effbot.org/zone/element-index.htm#usage

          Good luck