Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing regex in python to remove blank line in an XML?
    primarykey
    data
    text
    <p>Sorry if this has been asked before but I cannot find the answer anywhere..</p> <p>I am trying to use regex to extract element values but the xml being pulled contains a blank line and this seems to be causing errors.</p> <p>Here is one of the elements in the XML:</p> <pre><code>&lt;entry&gt; &lt;id&gt;http://feeds.rasset.ie/rteavgen/player/videos/show/?id=10103822&lt;/id&gt; &lt;showid&gt;10103822&lt;/showid&gt; &lt;platform&gt;iptv&lt;/platform&gt; &lt;published&gt;2013-01-19T21:45:00+00:00&lt;/published&gt; &lt;updated&gt;2013-01-19T23:41:00+00:00&lt;/updated&gt; &lt;title type="text"&gt;The Saturday Night Show&lt;/title&gt; &lt;content type="text"&gt;Chat show, presented by journalist and broadcaster Brendan O'Connor, featuring comedy, celebrity guests and live musical performances.&lt;/content&gt; &lt;category term="RTÉ One" rte:type="channel"/&gt; &lt;category term="Entertainment" rte:type="genre"/&gt; &lt;category term="None" rte:type="series"/&gt; &lt;category term="None" rte:type="episode"/&gt; &lt;category term="None" rte:type="ranking"/&gt; &lt;category term="1024" rte:type="genrelist"/&gt; &lt;category term="None" rte:type="keywordlist"/&gt; &lt;category term="1668" rte:type="progid"/&gt; &lt;link rel="self" type="application/atom+xml" href="http://feeds.rasset.ie/rteavgen/player/playlist?showId=10103822"/&gt; &lt;link rel="alternate" type="text/html" href="http://www.rte.ie/player/#v=10103822"/&gt; &lt;rte:valid start="2013-01-19T21:52:12+00:00" end="2013-02-09T21:52:12+00:00"/&gt; &lt;rte:duration ms="4201061" formatted="1:10"/&gt; &lt;rte:statistics views="194"/&gt; &lt;media:title type="plain"&gt;The Saturday Night Show&lt;/media:title&gt; &lt;media:description type="plain"&gt;Chat show, presented by journalist and broadcaster Brendan O'Connor, featuring comedy, celebrity guests and live musical performances.&lt;/media:description&gt; &lt;media:player url="http://feeds.rasset.ie/rteavgen/player/player/?id=" width="400" height="300"/&gt; &lt;media:thumbnail url="http://img.rasset.ie/0006e56a.jpg" time="00:00:00+00:00"/&gt; &lt;media:restriction relationship="allow" type="country"/&gt; &lt;media:restriction relationship="disallow" type="country"/&gt; &lt;media:copyright&gt;RTÉ&lt;/media:copyright&gt; &lt;/entry&gt; </code></pre> <p>You can see between the two "link rel=" elements there is a blank line.</p> <p>When I try to use this regex command it throws the Timeout! error as I'm not handling this properly (Excuse me also as my regex knowledge is almost zero). </p> <pre><code>links = (re.compile ('&lt;showid&gt;(.+?)&lt;/showid&gt;\n ' \ '&lt;platform&gt;.+?&lt;/platform&gt;\n ' \ '&lt;published&gt;(.+?)&lt;/published&gt;\n ' \ '&lt;updated&gt;.+?&lt;/updated&gt;\n ' \ '&lt;title type="text"&gt;(.+?)&lt;/title&gt;\n ' \ '&lt;content type="text"&gt;(.+?)&lt;/content&gt;\n ' \ '&lt;category term="(.+?)" rte:type="channel"/&gt;\n ' \ '&lt;category term=".+?" rte:type="genre"/&gt;\n ' \ '&lt;category term=".+?" rte:type="series"/&gt;\n ' \ '&lt;category term=".+?" rte:type="episode"/&gt;\n ' \ '&lt;category term=".+?" rte:type="ranking"/&gt;\n ' \ '&lt;category term=".+?" rte:type="genrelist"/&gt;\n ' \ '&lt;category term=".+?" rte:type="keywordlist"/&gt;\n ' \ '&lt;category term=".+?" rte:type="progid"/&gt;\n ' \ '&lt;link rel="self" type=".+?" href=".+?" /&gt;\n ' \ '&lt;link rel="alternate" type=".+?" href=".+?" /&gt;').findall(data)) </code></pre> <p>I only actually want a few of the fields but I can't seem to find a regex command that allows me to just select the individual element names I want, it makes me enter each one in sequence (again, my lack of regex knowledge is the issue). There are fields that I require beyond the second "link rel=" element that I require but as it keeps falling over on this one I have left them out for now.</p> <p>Anyone know what regex command I need to skip the blank line and also perhaps to tidy up the expression to only extract the elements that I require?</p> <p>Thanks for your help folks, I hope...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload