Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I assume that your challenge is parsing XML.</p> <pre><code>results_str = top_rated.read() splittedlist = results_str.split('&lt;entry') </code></pre> <p>And I see you are using string functions to parse XML. Such functions based on finite automata (regular languages) are NOT suited for parsing context-free languages such as XML. Expect it to break very easily.</p> <p>For more reasons, please refer <a href="https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454">RegEx match open tags except XHTML self-contained tags</a></p> <p><strong>Solution</strong>: consider using an XML parser like elementree. It comes with Python and allows you to browse the XML tree pythonically. <a href="http://effbot.org/zone/element-index.htm" rel="nofollow noreferrer">http://effbot.org/zone/element-index.htm</a></p> <p>Your may come up with code like:</p> <pre><code>import elementtree.ElementTree as ET .. results_str = top_rated.read() root = ET.fromstring(results_str) for node in root: print node </code></pre> <hr> <blockquote> <p>I also don't know how to use classes to do it.</p> </blockquote> <p>Don't be in a rush to create classes :-) </p> <p>In the above example, you are importing a module, not importing a class and instantiating/initializing it, like you do for Java. Python has powerful primitive types (dictionaries, lists) and considers modules as objects: so (IMO) you can go easy on classes. </p> <p>You use classes to organize stuff, not because your teacher has indoctrinated you "classes are good. Lets have lots of them".</p>
    singulars
    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.
    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