pretty-xml
pretty-xml copied to clipboard
Fix for prevents line breaks in tags with no content
I don't know if this functionality already exists, but that code fix that for me
Example of the problem:
$xmlTest = "<?xml version='1.0'?>
<root><Cliente><codigoIbge>234234423</codigoIbge><sCodigoEmpresa>345345345</sCodigoEmpresa><sDescricaoEmpresa>Teste Innersite</sDescricaoEmpresa><sEnderecoEmpresa></sEnderecoEmpresa><sBairroEmpresa>Centro</sBairroEmpresa><sCEPEmpresa>20020-010</sCEPEmpresa><sMunicipioEmpresa>Rio de Janeiro</sMunicipioEmpresa><iNumeroEmpresa>00</iNumeroEmpresa><sCGCCPFEmpresa>6546.4684.16464</sCGCCPFEmpresa><sFoneEmpresa>(21) 22222-2222</sFoneEmpresa><sUfEmpresa>RJ</sUfEmpresa><sEmailEmpresa>[email protected]</sEmailEmpresa><sPaisEmpresa></sPaisEmpresa><sComplementoEmpresa>
00</sComplementoEmpresa><sTipoPessoaEmpresa>F</sTipoPessoaEmpresa><sTransportadora>0</sTransportadora><sDescricaoEmpresa2></sDescricaoEmpresa2><sDescricaoEmpresa1></";
echo "<textarea rows='35' style='width:600px;>".(new Formatter())->format($xmlTest)."</textarea>";
Ideally there should be a test to illustrate the bad behaviour that this fixes
Sorry, I put the test but not the demonstration.
Code:
$xmlTeste2 = "<?xml version='1.0' encoding='UTF-8'?><SOAP-ENV:Envelope'><SOAP-ENV:Body><ns1:catalogProductList><sessionId xsi:type='xsd:string'>1569b2058f34e29</sessionId><filters xsi:type='ns1:filters'><complex_filter SOAP-ENC:arrayType='ns1:complexFilter[1]'><item xsi:type='ns1:complexFilter'><key xsi:type='xsd:string'>sku</key><value xsi:type='ns1:associativeEntity'><key xsi:type='xsd:string'>in</key><Code></Code></value></item></complex_filter></filters><storeView xsi:nil='true'/></ns1:catalogProductList></SOAP-ENV:Body></SOAP-ENV:Envelope>";
echo "<textarea rows='35' style='width:600px;>".(new Formatter())->format($xmlTeste2)."</textarea>";
@shanethehat
The PR was not merged because it did not provide any test coverage for the change, and additionally has merge conflicts that need to be resolved.
Even if it was merged now, the CI and CD systems that used to build and publish it are very out of date. I've been out of the PHP world for so long that I wouldn't know where to begin with getting it up to date!
ok, if you want to pass the ownership over to me, I would take care of the repo.