Skip to content

root and child with the same name #201

Open
@brunocunha00

Description

@brunocunha00

I have an unusual situation

the service I'm consuming returns the tag 'Address' and one of its children also has the tag 'Address' like the example below

`[Endereco] => Array
(

  [0] => Array
      (
          [name] => {http://www.abrasf.org.br/nfse.xsd}Endereco
          [value] => RUA CUIABA
          [attributes] => Array
              (
              )
      )

  [1] => Array
      (
          [name] => {http://www.abrasf.org.br/nfse.xsd}Numero
          [value] => 96
          [attributes] => Array
              (
              )
      )

  [2] => Array
      (
          [name] => {http://www.abrasf.org.br/nfse.xsd}Bairro
          [value] => Prado
          [attributes] => Array
              (
              )
      )

  [3] => Array
      (
          [name] => {http://www.abrasf.org.br/nfse.xsd}CodigoMunicipio
          [value] => 3106200
          [attributes] => Array
              (
              )
      )

  [4] => Array
      (
          [name] => {http://www.abrasf.org.br/nfse.xsd}Uf
          [value] => MG
          [attributes] => Array
              (
              )
      )
  [5] => Array
      (
          [name] => {http://www.abrasf.org.br/nfse.xsd}Cep
          [value] => 30411180
          [attributes] => Array
              (
              )
      )

)
`
so if I do the mapping of 'Address' it understands as if the two were root

$this->sabre->elementMap['{http://www.abrasf.org.br/nfse.xsd}Endereco'] = function($reader){ return \Sabre\Xml\Deserializer\keyValue($reader, 'http://www.abrasf.org.br/nfse.xsd'); };

`
[Endereco] => Array
(

  [Endereco] => Array () **_HERE SHOULD BE 'RUA A'_**
   [Numero] => 96
  [Bairro] => Prado
  [CodigoMunicipio] => 3106200
  [Uf] => MG
  [Cep] => 30411180

)`

as root and child have the same name it recognizes as an array and not as a string as it should be

what would be the best option to get around this problem? (sorry my english, i'm using translator)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions