Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected closing tags #16

Open
hashhesh opened this issue Jul 29, 2022 · 3 comments
Open

Unexpected closing tags #16

hashhesh opened this issue Jul 29, 2022 · 3 comments

Comments

@hashhesh
Copy link

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
Copy link
Author

Hi, just to update, after change to SabreXMLWriterService it works fine but honestly I still don't know why?!!!!!

@AaronDDM
Copy link
Owner

Hey @hashhesh , that is indeed strange! Thanks for reporting this. I’ll check it out and get back to you - you might have discovered a bug!

I’m glad you have a workaround at least.

@hashhesh
Copy link
Author

hello @AaronDDM , highly appreciated your swift reply. I'm really curious to know what's the issue too.

Thanks again Aaron.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants