À l'aide de xpath pour extraire des données d'une colonne XML dans postgres

J'ai fait le tableau suivant:

create table temp.promotions_xml(id serial promotion_xml xml);

J'ai inséré les données suivantes dans la temp.promotions:

<promotions xmlns="http://www.demandware.com/xml/impex/promotion/2008-01-31">
    <campaign campaign-id="2013-1st-semester-jet-giveaways">
        <description>2013 1st Semester Jet Giveaways</description>
        <enabled-flag>true</enabled-flag>
        <start-date>2013-01-01T05:00:00.000Z</start-date>
        <end-date>2013-07-01T04:00:00.000Z</end-date>
        <customer-groups>
            <customer-group group-id="Everyone"/>
        </customer-groups>
    </campaign>
</promotions>

Les données sont dans le tableau.

Je ne peux pas comprendre comment le sortir. Je vais probablement voulez être en mesure de remplir un modèle relationnel que je vais développer, donc je veux me débarrasser de tous les de la balise.

Ci-dessous sont quelques questions que j'ai essayé qui ne fonctionnent pas. Je suis assez sûr que je suis en dansant autour de la syntaxe correcte. Ces requêtes renvoient des lignes vides ensembles.

FWIW, nous sommes à l'aide de Postgres 9.0.4.

Merci, --sw

select xpath('/promotions/campaign/description/text()',promotion_xml) textcol from temp.promotions_xml
select xpath('./promotions/campaign/description/text()',promotion_xml) textcol from temp.promotions_xml
select xpath('promotions/campaign/description/text()',promotion_xml) textcol from temp.promotions_xml
select xpath('///description/text()',promotion_xml) textcol from temp.promotions_xml
select xpath('//description/text()',promotion_xml) textcol from temp.promotions_xml
select xpath('.//description/text()',promotion_xml) textcol from temp.promotions_xml
select xpath('./campaign/description/text()',promotion_xml) textcol from temp.promotions_xml
select xpath('//campaign/description/text()',promotion_xml) textcol from temp.promotions_xml

OriginalL'auteur Scott Wood | 2013-07-23