Giter Site home page Giter Site logo

php-fast-xml-parser's Issues

Problem with nested elements with the same names

Hello,

I got problem with elements which are nested and have the same name. For example on given XML:
<ITEM> <NAME>Basic item</NAME> <VALUE>10</VALUE> <TYPES> <TYPE> <NAME>Black</NAME> </TYPE> <TYPE> <NAME>White</NAME> </TYPE> </TYPES> </ITEM>

I had set up the parser end tag to ITEM:
$parser->setEndTag('ITEM');

When I want to access to value of NAME the given result isn't just "Basic item", but "Basic Item Black White". What I should do to ignore the nested elements value? But I also need to access data of the nested elements (so I can't use setIgnoreTags(['TYPES']))? It will be ok for me if the data will be separated somehow for example with semicolon, (Basic item;Black;White). Is it possible?

Thank you.

Problems with merge attributes

<Товар>
                <Ид>141039a8-46e3-11e3-a6c1-00270e0f5cf8</Ид>
                <Штрихкод>9999989000365</Штрихкод>
                <БазоваяЕдиница Код="796" НаименованиеПолное="Штука" МеждународноеСокращение="PCE">шт</БазоваяЕдиница>
                <Группы>
                    <Ид>726f6435-3fd4-11e3-a6c1-00270e0f5cf8</Ид>
                </Группы>
                <КатегорияНовинка>0</КатегорияНовинка>
                <КатегорияРекомендуем>0</КатегорияРекомендуем>
                <КатегорияСкидка>0</КатегорияСкидка>
                <КатегорияСкороВПродаже>0</КатегорияСкороВПродаже>
                <ЗначенияСвойств>
                    <ЗначенияСвойства>
                        <Ид>d67561d5-5b5f-4b4f-916a-d3c28b0cfd66</Ид>
                        <Значение/>
                    </ЗначенияСвойства>
                    <ЗначенияСвойства>
                        <Ид>c54fb036-365f-11df-9de2-00270e0f5cf8</Ид>
                        <Значение/>
                    </ЗначенияСвойства>
                    <ЗначенияСвойства>
                        <Ид>1bc95de3-33ce-4c66-b9df-0f6ce9c48ab1</Ид>
                        <Значение/>
                    </ЗначенияСвойства>
                </ЗначенияСвойств>
                <СтавкиНалогов>
                    <СтавкаНалога>
                        <Наименование>НДС</Наименование>
                    </СтавкаНалога>
                </СтавкиНалогов>
                <ЗначенияРеквизитов>
                    <ЗначениеРеквизита>
                        <Наименование>ВидНоменклатуры</Наименование>
                        <Значение>Товар</Значение>
                    </ЗначениеРеквизита>
                    <ЗначениеРеквизита>
                        <Наименование>ТипНоменклатуры</Наименование>
                        <Значение>Товар</Значение>
                    </ЗначениеРеквизита>
                    <ЗначениеРеквизита>
                        <Наименование>Полное наименование</Наименование>
                        <Значение>Художников 36</Значение>
                    </ЗначениеРеквизита>
                    <ЗначениеРеквизита>
                        <Наименование>Вес</Наименование>
                        <Значение>0</Значение>
                    </ЗначениеРеквизита>
                </ЗначенияРеквизитов>
            </Товар>

Результат

[Ид] => 141039b7-46e3-11e3-a6c1-00270e0f5cf8726f6435-3fd4-11e3-a6c1-00270e0f5cf8d67561d5-5b5f-4b4f-916a-d3c28b0cfd66c54fb036-365f-11df-9de2-00270e0f5cf81bc95de3-33ce-4c66-b9df-0f6ce9c48ab1

склеил все значения ИД

Can you define a license?

Hello, is this project in a liberal use license such as a MIT, Apache, FreeBSD style license?

Thanks

Symfony EventDispatcher Dependency

hi alex,
how to dependency list symfony component, without symfony symfony framework

use Symfony\Component\EventDispatcher\EventDispatcher;

utf8_decode is deprecated as of PHP8.2 (and probably wrong too)

first off, utf8_decode() is deprecated as of PHP8.2, and you should use

mb_convert_encoding($str, 'utf-8', 'ISO-8859-1')

instead,

second, utf8_decode converts data from ISO-8859-1 to UTF-8,
which means that if your XML document is not encoded with ISO-8859-1, the function

    /**
     * Replaces all html entities into its original symbols.
     * 
     * @param string $content
     * @return string
     */
    public function convertEntities($content)
    {
        $table = array_map('utf8_encode', array_flip(
            array_diff(
                get_html_translation_table(HTML_ENTITIES), 
                get_html_translation_table(HTML_SPECIALCHARS)
            )
        ));
        return preg_replace('/&#[\d\w]+;/', '', strtr($content, $table));
    }

doesn't even make sense, and is likely to corrupt UTF-8 XMLs..

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.