Note that there are some explanatory texts on larger screens.

plurals
  1. POReading non well-formed XML file without quotation marks in attribute - python
    primarykey
    data
    text
    <p>I have an xml-like file that doesn't have the quotation marks in the attribute <code>attribute="xxx"</code> and it doesn't have a the standard <code>&lt;?xml version="1.0"?&gt;</code> header so when I tried to parse with <code>minidom</code> or <code>elementtree</code>, they complained the file as <code>not well-formed</code>: </p> <pre><code>&gt;&gt;&gt; import xml.etree.ElementTree as et &gt;&gt;&gt; tree = et.parse(infile) &gt;&gt;&gt; Traceback (most recent call last): xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, column 25 </code></pre> <p><strong>How do I read the input file? Or how could I make the xml well-formed?</strong></p> <p>My input file looks like this:</p> <pre><code>&lt;contextfile concordance=brown&gt; &lt;context filename=br-a01 paras=yes&gt; &lt;p pnum=1&gt; &lt;s snum=1&gt; &lt;wf cmd=ignore pos=DT&gt;The&lt;/wf&gt; &lt;wf cmd=done rdf=group pos=NNP lemma=group wnsn=1 lexsn=1:03:00:: pn=group&gt;Fulton_County_Grand_Jury&lt;/wf&gt; &lt;wf cmd=done pos=VB lemma=say wnsn=1 lexsn=2:32:00::&gt;said&lt;/wf&gt; &lt;wf cmd=done pos=NN lemma=friday wnsn=1 lexsn=1:28:00::&gt;Friday&lt;/wf&gt; &lt;wf cmd=ignore pos=DT&gt;an&lt;/wf&gt; &lt;wf cmd=done pos=NN lemma=investigation wnsn=1 lexsn=1:09:00::&gt;investigation&lt;/wf&gt; &lt;wf cmd=ignore pos=IN&gt;of&lt;/wf&gt; &lt;wf cmd=done pos=NN lemma=atlanta wnsn=1 lexsn=1:15:00::&gt;Atlanta&lt;/wf&gt; &lt;wf cmd=ignore pos=POS&gt;'s&lt;/wf&gt; &lt;wf cmd=done pos=JJ lemma=recent wnsn=2 lexsn=5:00:00:past:00&gt;recent&lt;/wf&gt; &lt;wf cmd=done pos=NN lemma=primary_election wnsn=1 lexsn=1:04:00::&gt;primary_election&lt;/wf&gt; &lt;wf cmd=done pos=VB lemma=produce wnsn=4 lexsn=2:39:01::&gt;produced&lt;/wf&gt; &lt;punc&gt;``&lt;/punc&gt; &lt;wf cmd=ignore pos=DT&gt;no&lt;/wf&gt; &lt;wf cmd=done pos=NN lemma=evidence wnsn=1 lexsn=1:09:00::&gt;evidence&lt;/wf&gt; &lt;punc&gt;''&lt;/punc&gt; &lt;wf cmd=ignore pos=IN&gt;that&lt;/wf&gt; &lt;wf cmd=ignore pos=DT&gt;any&lt;/wf&gt; &lt;wf cmd=done pos=NN lemma=irregularity wnsn=1 lexsn=1:04:00::&gt;irregularities&lt;/wf&gt; &lt;wf cmd=done pos=VB lemma=take_place wnsn=1 lexsn=2:30:00::&gt;took_place&lt;/wf&gt; &lt;punc&gt;.&lt;/punc&gt; &lt;/s&gt; &lt;/p&gt; &lt;/context&gt; &lt;/contextfile&gt; </code></pre>
    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.
 

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