【发布时间】:2018-01-12 05:18:52
【问题描述】:
我在 Postgresql 9.4 中遇到问题,使用命名空间查询 xml 字段。
我正在使用以下内容:
select unnest(xpath('/cfdi:Comprobante/cfdi:Receptor/text()',
xmlfield,
array[array['cfdi:','http://www.sat.gob.mx/cfd/3']])) AS "receptor"
from mytable;
我的 xml 字段看起来像
<cfdi:Comprobante
Version="3.3" Serie="W" Folio="713"
Fecha="2018-01-09T20:18:41" FormaPago="99"
NoCertificado="0022" CondicionesDePago="CONTADO"
SubTotal="5450.53" Moneda="MXN"
Total="6322.61" TipoDeComprobante="I"
MetodoPago="PUE" LugarExpedicion="55525"
Sello="N4MxzjrIqV/GOgUOw=="
xsi:schemaLocation="http://www.sat.gob.mx/cfd/3
http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv33.xsd"
Certificado="MIIsK2A=="
xmlns:cfdi="http://www.sat.gob.mx/cfd/3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<cfdi:Emisor
Rfc="MIO180526WW9"
Nombre="MI EMPRESA"
RegimenFiscal="601" />
<cfdi:Receptor
Rfc="TUYO191111SOY"
Nombre="OSCAR TUNEZ YUNEZ"
UsoCFDI="P01" />
<cfdi:Conceptos>
<cfdi:Concepto
ClaveProdServ="151" Cantidad="599.299526" Descripcion="CHIVA FLACA"
Importe="5450.53" ClaveUnidad="LTR" Unidad="LITRO"
ValorUnitario="9.094828">
<cfdi:Impuestos>
<cfdi:Traslados>
<cfdi:Traslado
Base="5450.53"
Impuesto="002"
TipoFactor="Tasa"
TasaOCuota="0.16"
Importe="872.08" />
</cfdi:Traslados>
</cfdi:Impuestos>
</cfdi:Concepto>
</cfdi:Conceptos>
<cfdi:Impuestos TotalImpuestosTrasladados="872.08">
<cfdi:Traslados>
<cfdi:Traslado
Impuesto="002"
TipoFactor="Tasa"
TasaOCuota="0.16"
hImporte="872.08" />
</cfdi:Traslados>
</cfdi:Impuestos>
<cfdi:Complemento>
<tfd:TimbreFiscalDigital
Version="1.1" UUID="138"
FechaTimbrado="2019-07-09T20:18:48"
RfcProvCertif="MET310111MX9"
SelloCFD="fQVVPfUOw=="
SelloSAT="6PHUGnorpHQ=="
NoCertificadoSAT="007"
xsi:schemaLocation="http://www.sat.gob.mx/TimbreFiscalDigital
http://www.sat.gob.mx/sitio_internet/cfd/timbrefl/TimbreFlv11.xsd"
xmlns:tfd="http://www.sat.gob.mx/TimbreFiscalDigital" />
</cfdi:Complemento>
</cfdi:Comprobante
我正在努力 cfdi:Comprobante cfdi:受体 Rfc="TUYO191111SOY" Nombre="OSCAR TUNEZ YUNEZ"
但是使用之前的查询返回
ERROR: could not create XPath object
DETAIL: Undefined namespace prefix
********** Error **********
ERROR: could not create XPath object
SQL state: XX000
Detail: Undefined namespace prefix
我做错了什么? 提前致谢
【问题讨论】:
标签: xml postgresql