-3
I select to bring an xml file that is stored as a blob in the oracle database. I read the file and save the contents in a variable. When checking the type of the variable is of type bytes. I do the conversion using Code but the content is corrupted. What can it be?? Follow my code:
def retornaXml(seqXml):
# 321527
cur = OracleConfig().conn.cursor()
cur.execute(f"SELECT BinArq FROM SDE_TESTE.N100XML WHERE N100XML.SeqXml = {seqXml}")
rows = cur.fetchall()
blobXml = rows[0][0]
xmlDoc = blobXml.read()
xmlDoc = xmlDoc.decode()
del blobXml
return xmlDoc
The way out is:
<�? xml version="1.0" encoding="utf-8"? >< cteProc versao="3.00" xmlns="http://www.portalfiscal.inf.br/cte">< Cte xmlns="http://www.portalfiscal.inf.br/cte">< infCte Id="Cte41210481437048000163570000319231000321806" versao="3.00"><�ide><�cUF>41<�/cUF><�cCT>00032180<�/cCT><�CFOP>5352<�/CFOP><�natOp>Prest.Servico Transporte a Estab.Indl.<�/natOp><�mod>57<�/mod><�serie>1<�/serie><�nCT>31923<�/nCT><�dhEmi>2021-04-22T15:10:00-03:00<�/dhEmi><�tpImp>1<�/tpImp><�tpEmis>1<�/tpEmis><�cDV>6<�/cDV><�tpAmb>1<�/tpAmb><�tpCTe>0<�/tpCTe><�procEmi>0<�/procEmi><�verProc>5.10.1.50<�/verProc><�cMunEnv>4106902<�/cMunEnv><�xMunEnv>CURITIBA...
As you can see it’s corrupted. How can I fix this?
It is not the same problem that I had. The answer you put does not solve my problem, but okay. I have found the solution
– Gilberto Araujo Gomes Junior