Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Empty parsing results (opencv xml output)

Iam trying to parse xml (with standart python xml.etree.ElementTree) output from opencv 3.4.2 with python 3.7, results are empty.

Maybe the problem is about data type, which iam trying to extract?

XML sample: https://yadi.sk/d/DFTMQU5jz7MxNQ

Code sample:

import xml.etree.ElementTree as ET
root = ET.parse('new.xml').getroot()  
data = opencv_lbphfaces.find('histograms').text
print('histograms : ', data)

I also tried this (its still show empty result at histograms):

import xml.etree.ElementTree as ET
root = ET.parse('new.xml').getroot()  
for opencv_lbphfaces in root.findall('opencv_lbphfaces'):
for element in opencv_lbphfaces:
     ele_name = element.tag
     ele_value = opencv_lbphfaces.find(element.tag).text
     print(ele_name, ' : ', ele_value)

I want to extract opencv_lbphfaces/histograms/data, after save into file and convert from exponential to integer. But stack at extraction part.

Please give me advice how to solve this histograms extraction problem