Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can you parse xml in Google Refine using jython/python ElementTree
    text
    copied!<p>I trying to parse some xml in Google Refine using Jython and ElementTree but I'm struggling to find any documentation to help me getting this working (probably not helped by not being a python coder)</p> <p>Here's an extract of the XML I'm trying to parse. I'm trying to return a joined string of all the <code>dc:indentifier</code>:</p> <pre><code>&lt;oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd"&gt; &lt;dc:creator&gt;J. Koenig&lt;/dc:creator&gt; &lt;dc:date&gt;2010-01-13T15:47:38Z&lt;/dc:date&gt; &lt;dc:date&gt;2010-01-13T15:47:38Z&lt;/dc:date&gt; &lt;dc:date&gt;2010-01-13T15:47:38Z&lt;/dc:date&gt; &lt;dc:identifier&gt;CCTL0059&lt;/dc:identifier&gt; &lt;dc:identifier&gt;CCTL0059&lt;/dc:identifier&gt; &lt;dc:identifier&gt;http://open.jorum.ac.uk:80/xmlui/handle/123456789/335&lt;/dc:identifier&gt; &lt;dc:format&gt;application/pdf&lt;/dc:format&gt; &lt;/oai_dc:dc&gt; </code></pre> <p>Here's the code I've got so far. This is a test to return anything as right now all I'm getting is 'Error: null'</p> <pre><code>from elementtree import ElementTree as ET element = ET.parse(value) namespace = "{http://www.openarchives.org/OAI/2.0/oai_dc/}" e = element.findall('{0}identifier'.format(namespace)) for i in e: count += 1 return count </code></pre>
 

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