Note that there are some explanatory texts on larger screens.

plurals
  1. POParsing XML/HTML encoded GChats
    primarykey
    data
    text
    <p>I'm attempting to learn XML in order to parse GChats downloaded from GMail via IMAP. To do so I am using lxml. Each line of the chat messages is formatted like so:</p> <pre><code>&lt;cli:message to="email@gmail.com" iconset="square" from="email@gmail.com" int:cid="insertid" int:sequence-no="1" int:time-stamp="1236608405935" xmlns:int="google:internal" xmlns:cli="jabber:client"&gt; &lt;cli:body&gt;Nikko&lt;/cli:body&gt; &lt;met:google-mail-signature xmlns:met="google:metadata"&gt;0c7ef6e618e9876b&lt;/met:google-mail- signature&gt; &lt;x stamp="20090309T14:20:05" xmlns="jabber:x:delay"/&gt; &lt;time ms="1236608405975" xmlns="google:timestamp"/&gt; &lt;/cli:message&gt; </code></pre> <p>When I try to build the XML tree like so:</p> <pre><code>root = etree.Element("cli:message") </code></pre> <p>I get this error:</p> <pre><code>Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; File "lxml.etree.pyx", line 2568, in lxml.etree.Element (src/lxml/lxml.etree.c:52878) File "apihelpers.pxi", line 126, in lxml.etree._makeElement (src/lxml/lxml.etree.c:11497) File "apihelpers.pxi", line 1542, in lxml.etree._tagValidOrRaise (src/lxml/lxml.etree.c:23956) ValueError: Invalid tag name u'cli:message' </code></pre> <p>When I try to escape it like so:</p> <pre><code>root = etree.Element("cli\:message") </code></pre> <p>I get the exact same error. </p> <p>The header of the chats also gives this information, which seems relevant:</p> <pre><code>Content-Type: text/xml; charset=utf-8 Content-Transfer-Encoding: 7bit </code></pre> <p>Does anyone know what's going on here?</p>
    singulars
    1. This table or related slice is empty.
    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.
    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