Unexpected closing tags
hashhesh opened this issue · 3 comments
hashhesh commented
Hi @AaronDDM
thanks for this lib it's more connivant.
Could you please help I have came across with really weird closing tag accidently even i didn't understood how/why
So this is my code
$xmlWriterService = new XMLWriterService();
$xml_builder_obj = new XMLBuilder($xmlWriterService);
$root = $xml_builder_obj->createXMLArray()->start('ProductData');
$root->loop(
function (XMLArray $XMLArray) use ($results, $relatives_tags, $product_type_attributes) {
foreach ($product_type_attributes as $tag_index => $tag_value) {
if (is_array($tag_value) && fn_he_amazon_array_depth($tag_value) === 1) {
$groups = $relatives_tags(key($tag_value));
$XMLArray->add(key($tag_value), $results[$groups[1]], [explode(',',$groups[2])[2] => $results[$groups[2]]]);
} else {
$XMLArray->add($tag_index, $tag_value);
}
}
});
$root->end();
and this is the outcomes
<?xml version="1.0" encoding="UTF-8"?>
<ProductData>
<Viscosity>2T</Viscosity>
<BatteryAverageLife unitOfMeasure="days">2</BatteryAverageLife>
</ProductData>
<ColorMap>beige</ColorMap>
<SizeMap>XX-Small</SizeMap>
<CompatibleWithVehicleType>Airplane</CompatibleWithVehicleType>
while the expected output is like below:
<?xml version="1.0" encoding="UTF-8"?>
<ProductData>
<Viscosity>2T</Viscosity>
<BatteryAverageLife unitOfMeasure="days">2</BatteryAverageLife>
<ColorMap>beige</ColorMap>
<SizeMap>XX-Small</SizeMap>
<CompatibleWithVehicleType>Airplane</CompatibleWithVehicleType>
</ProductData>
ProductData
should be closed at the end not to be closed after the second tag.
I have used startLoop
and using $root
instead of XMLArray
but the same result.
So, Could you please help to understand this issue? though if I comment the first if statement it's works fine.
Thanks in advance
hashhesh commented
Hi, just to update, after change to SabreXMLWriterService
it works fine but honestly I still don't know why?!!!!!