I'm working with a Postgresql DB. table is ticketlines containes a bytea field called attributes
Sample of field contents in JSON view:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<comment>Ticket Attributes</comment>
<entry key="product.candiscount">true</entry>
<entry key="product.categoryid">8410a5e3-fc31-4370-b7da-d8406d80ca97</entry>
<entry key="product.kitchen">false</entry>
<entry key="product.com">false</entry>
<entry key="product.alwaysavailable">false</entry>
<entry key="product.service">true</entry>
<entry key="product.warranty">false</entry>
<entry key="product.taxcategoryid">000</entry>
<entry key="product.vprice">false</entry>
<entry key="product.discounted">no</entry>
<entry key="notes">006942</entry>
<entry key="product.texttip"/>
<entry key="product.nosc">0</entry>
<entry key="product.promotionadded">false</entry>
<entry key="product.name">Pawn Payout</entry>
<entry key="product.code">pp</entry>
<entry key="product.ispack">false</entry>
<entry key="product.alias"/>
<entry key="product.verpatrib">false</entry>
<entry key="product.managestock">true</entry>
</properties>
Is there a simple way to query this data for reporting in a SELECT statement (ie; SELECT product.name, notes ) ?
I'm close with this: but obviously have the structure wrong: SELECT xpath('//properties:notes/text()', CAST(convert_from(attributes, 'UTF-8') AS XML)) FROM ticketlines where ticket='7abc41d9-0d7f-4187-bb81-e4139d7728bf'
the results are: ERROR: invalid XML content DETAIL: line 2: StartTag: invalid element name ^ *** Error *** ERROR: invalid XML content SQL state: 2200N Detail: line 2: StartTag: invalid element name