Skip to content

nested elements with only one child are ignored #1471

Description

@legrostdg

I'm using zeep version 4.3.1.

Is there a way to avoid ignoring the nested elements with only one child in the response?

For example, given this xml response:

<?xml version=\'1.0\' encoding=\'UTF-8\'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
  <S:Body>
    <Operation1Response xmlns="http://www.example.com/XML/Schema/" xmlns:ns2="http://www.example.com/types/">
      <ReponseStandard>
        <ns2:Resultat>false</ns2:Resultat>
        <ns2:Anomalie>
          <ns2:Severite>1</ns2:Severite>
          <ns2:Message>Error Message</ns2:Message>
          </ns2:Anomalie>
      </ReponseStandard>
    </Operation1Response>
  </S:Body>
</S:Envelope>

zeep gives me this structure:

{
    'Resultat': False,
    'Anomalie': {
        'Severite': 1,
        'Message': 'Error Message'
    }
}

while

<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
  <S:Body>
    <Operation2Response xmlns="http://www.example.com/XML/Schema/" xmlns:ns2="http://www.example.com/types/">
      <ReponseStandard>
        <ns2:Resultat>true</ns2:Resultat>
      </ReponseStandard>
      <ReponseSpecifique>
        <Number>0</Number>
      </ReponseSpecifique>
    </Operation2Response>
  </S:Body>
</S:Envelope>

gives:

{
    'ReponseStandard': {
        'Resultat': True,
        'Anomalie': None
    },
    'ReponseSpecifique': {
        'Number': 0,
        'Message': None
    }
}

I get that this way of parsing avoids typing overhead (having to specify Operation1Response), but it seems wrong to ignore ReponseStandard in the first example. I would expect to have:

{
    'ReponseStandard': {
        'Resultat': False,
        'Anomalie': {
            'Severite': 1,
            'Message': 'Error Message'
        }
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions