A
A
alenkaci2020-06-18 18:54:42
Python
alenkaci, 2020-06-18 18:54:42

How to extract XML data from PostgreSQL for further processing in python?

Good day everyone!
Help with solving the problem)
I extract from the xml database, which is stored in the body field of the table table with the following function

cursor.execute('select convert_from(body, %(form)s) from table limit 1' )
a=cursor.fetchone()

I get the line:
('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><head xmlns="http://ссылка "><MessageID>1<.MessageID></head>')


how to spread this line then?
Visited tree = ET.parse(a) - doesn't work(

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
soremix, 2020-06-18
@alenkaci

ET.parse() takes a file, you need ET.fromstring()

D
Dr. Bacon, 2020-06-18
@bacon

because "a" is a tuple, not a string

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question