@n199a
Java

Как правильно организовать SAX парсер в Java?

Имеется xml-документ:
Нажми, чтобы открыть

<tariffs xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://tarasiuk.by/task02"
         xsi:schemaLocation="https://tarasiuk.by/task02 Tariffs.xsd">
    <mobile-connection id="T01">
        <tariff-information>
            <tariff-name>Unlimited</tariff-name>
            <description>Unlimited internet and unlimited calls.</description>
            <date-creation>2021-05-08</date-creation>
            <time-creation>08:00:00</time-creation>
        </tariff-information>
        <operator country="BY">
            <simple-name>MTS</simple-name>
            <full-name>Mobile TeleSystems JLLC</full-name>
        </operator>
        <parameters>
            <count-favorite-numbers>3</count-favorite-numbers>
            <tariffication>twelve seconds</tariffication>
        </parameters>
        <default-price currency="BYN">
            <connection-to-tariff>00.00</connection-to-tariff>
            <payroll>15.78</payroll>
            <send-sms>1.0</send-sms>
        </default-price>
        <call-price currency="BYN">
            <on-mobile-phone>
                <inside-operator>0.05</inside-operator>
                <outside-operator>1.15</outside-operator>
            </on-mobile-phone>
            <on-landline-phone>2.00</on-landline-phone>
        </call-price>
    </mobile-connection>
    <mobile-internet id="T02">
        <tariff-information>
            <tariff-name>Unlimited</tariff-name>
            <description>Unlimited internet and unlimited calls.</description>
            <date-creation>2021-05-08</date-creation>
            <time-creation>08:00:00</time-creation>
        </tariff-information>
        <operator country="BY">
            <simple-name>MTS</simple-name>
            <full-name>Mobile TeleSystems JLLC</full-name>
        </operator>
        <parameters>
            <count-favorite-numbers>3</count-favorite-numbers>
            <tariffication>twelve seconds</tariffication>
        </parameters>
        <default-price currency="BYN">
            <connection-to-tariff>00.00</connection-to-tariff>
            <payroll>15.78</payroll>
            <send-sms>1.0</send-sms>
        </default-price>
        <call-price currency="BYN">
            <on-mobile-phone>
                <inside-operator>0.05</inside-operator>
                <outside-operator>1.15</outside-operator>
            </on-mobile-phone>
            <on-landline-phone>2.00</on-landline-phone>
        </call-price>
        <internet-price currency="BYN">
            <up-one-gb>1.00</up-one-gb>
            <over-one-gb>0.90</over-one-gb>
        </internet-price>
    </mobile-internet>
</tariffs>



Создана уже структура данного xml-документа в виде классов:
Нажми, чтобы открыть

60a196c6298ee170915348.jpeg


Не могу никак уже 5 дней составить этот SAX-парсер.
  • Вопрос задан
  • 85 просмотров
Пригласить эксперта
Ответы на вопрос 2
leahch
@leahch
3D специалист. Dолго, Dорого, Dерьмово.
А зачем вам столько тайп-классов? Все *-price тупые мапы Strung, Float...
Не надо каждый тег в класс оборачивать.
И если файло здоровое, то используйте Stax.
Лично я ничего сложного не вижу.
А ещё лучше объединить с jaxb https://stackoverflow.com/questions/25643097/can-a...
Ответ написан
Комментировать
BorLaze
@BorLaze
Java developer
Открываешь мануал и пишешь.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы