Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

222
Vistas
Postgresql - How to read xmlattributes on xml?

I Have xml :

<?xml version="1.0" encoding="UTF-8"?>
<attachments>
  <entry file="cewe_gw.jpg" name="cewe_gw.jpg"/>
  <entry file="wp1827515.png" name="wp1827515.png"/>
</attachments>

I want to get list file? ex:

cewe_gw.jpg
wp1827515.png
over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

If you are looking for a Postgres solution, then you can use xmltable for this:

select x.*
from the_table t
  cross join xmltable('/attachments/entry'
                      passing t.the_xml_column
                      columns file text path '@name') as x

This returns the value of the attribute name, if you want the file attribute, you need to change @name to @file

Online example

over 4 years ago · Santiago Trujillo Denunciar

0

demo:db<>fiddle

To select any element or attribute, you can use XPath:

SELECT 
    xpath('//entry/@file',xml)
FROM mydata

This returns an array of file attributes. You can extract them using unnest()

SELECT 
    unnest(xpath('//entry/@file',xml))
FROM mydata
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda