<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Python Programming help please' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Python Programming help please' posted on the 'Python' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2012 Programmers Heaven</copyright>
    <pubDate>Thu, 24 May 2012 00:15:56 -0700</pubDate>
    <lastBuildDate>Thu, 24 May 2012 00:15:56 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Python Programming help please</title>
      <link>http://www.programmersheaven.com/mb/python/417264/417264/python-programming-help-please/</link>
      <description>Hi there,&lt;br /&gt;
&lt;br /&gt;
I got this txt file with following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;GLOSSARY&amp;gt;&lt;br /&gt;
&amp;lt;INFO&amp;gt;&lt;br /&gt;
&amp;lt;NAME&amp;gt;My Glossary&amp;lt;/NAME&amp;gt;&lt;br /&gt;
&amp;lt;INTRO&amp;gt;stuff&amp;lt;/INTRO&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above text is saved in test.txt file.&lt;br /&gt;
&lt;br /&gt;
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 &amp;lt;Name&amp;gt; to &amp;lt;/Name&amp;gt; in python.&lt;br /&gt;
&lt;br /&gt;
If anybody can help me please with the code. I've tried searching a lot on net but haven't found anything.&lt;br /&gt;
&lt;br /&gt;
Thank You&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/417264/417264/python-programming-help-please/</guid>
      <pubDate>Wed, 16 Jun 2010 23:00:12 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Re: Python Programming help please</title>
      <link>http://www.programmersheaven.com/mb/python/417264/417299/re-python-programming-help-please/#417299</link>
      <description>&lt;pre class="sourcecode"&gt;
import re

name_block = re.compile('&amp;lt;Name&amp;gt;(?P&amp;lt;name&amp;gt;.*)&amp;lt;/Name&amp;gt;')

def get_name_block():
    #open the file for reading
    file_name = "test.txt"
    f = open(file_name, 'r')
    
    #look through it one line at a time
    name_block = ""
    search_result = None
    for l in f:
        search_result = name_block.match(l)
        if search_result:
            name_block = search_result.groups[0]
    return name_block
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
That will have a problem if &amp;lt;Name&amp;gt;...&amp;lt;/Name&amp;gt; spans over multiple lines, because "for l in f" pulls one line at a time.  In that case, no one line would ever match the regex.  Hope that works for you!&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/417264/417299/re-python-programming-help-please/#417299</guid>
      <pubDate>Fri, 18 Jun 2010 10:09:46 -0700</pubDate>
      <category>Python</category>
    </item>
  </channel>
</rss>
