Postgresql: Using xpath to extract data from an XML column
<p>I've been trying to extract values from XML the same way as <em>@Erwin Brandstetter</em> answered a few times with an accepted answer, but it just doesn't work for me:</p>

<p>According to <a href="https://stackoverflow.com/questions/16023523/extracting-value-of-xml-tag-in-postgresql">this post</a> and <a href="https://stackoverflow.com/questions/17799790/using-xpath-to-extract-data-from-an-xml-column-in-postgres">this post</a> this should work, but I just get an <strong>empty</strong> result:</p>

<pre><code>WITH x AS ( SELECT
   '&lt;Attributes xmlns="http://www.gis34.dk"&gt;
        &lt;bemaerkning displayName="Bemærkning"&gt;Beatrix&lt;/bemaerkning&gt;
        &lt;billede displayName="Billede"&gt;https://vignette.wikia.nocookie.net/killbill/images/3/39/The_Bride.jpg&lt;/billede&gt;
    &lt;/Attributes&gt;'::xml AS t
)

SELECT xpath('/Attributes/bemaerkning/text()', t) as comment
FROM   x
</code></pre>

<p>Result:
(expected: {My comment})</p>

<pre><code>comment
xml[]
-------
{}
</code></pre>

<p>My database version:</p>

<pre><code>PostgreSQL 9.1.3 on x86_64-unknown-linux-gnu, compiled by gcc-4.5.real (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2, 64-bit
</code></pre>

<p>Anyone has an idea?</p>