xml icon indicating copy to clipboard operation
xml copied to clipboard

root and child with the same name

Open brunocunha00 opened this issue 4 years ago • 0 comments

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)

brunocunha00 avatar Apr 28 '21 13:04 brunocunha00