[Python] Python ElementTree returning empty attributes

Discussão em 'Python' iniciado por Stack, Setembro 3, 2025.

  1. Stack

    Stack Membro Participativo

    The following code:

    import xml.etree.ElementTree as ET

    essai = '''<?xml version='1.0' standalone='yes' ?>
    <LVData xmlns="http://www.ni.com/LVData">
    <Version>18.0.1f4</Version>
    <Cluster>
    <Name>Out</Name>
    <NumElts>34</NumElts>
    <DBL>
    <Name>Amplitude_Signal</Name>
    <Val>0.30000000000000</Val>
    </DBL>
    </Cluster>
    </LVData>'''

    root = ET.fromstring(essai)
    for child in root[1]:
    print(child.tag, child.attrib)


    produces empty attribute results:

    {http://www.ni.com/LVData}Name {}
    {http://www.ni.com/LVData}NumElts {}
    {http://www.ni.com/LVData}DBL {}


    Why?

    Continue reading...

Compartilhe esta Página