Форум по Delphi программированию

Delphi Sources



Вернуться   Форум по Delphi программированию > Все о Delphi > [ "Начинающим" ]
Ник
Пароль
Регистрация <<         Правила форума         >> FAQ Пользователи Календарь Поиск Сообщения за сегодня Все разделы прочитаны

Ответ
 
Опции темы Поиск в этой теме Опции просмотра
  #1  
Старый 11.05.2020, 12:47
Gareth Gareth вне форума
Активный
 
Регистрация: 21.03.2013
Адрес: Приднестровье
Сообщения: 202
Версия Delphi: Delphi 7
Репутация: 10
По умолчанию XML одинаковые теги

Доброе время суток, подскажите пожалуйста, как мне спарсить значения с одинаковых тегов?
Код HTML:
This XML file does not appear to have any style information associated with it. The document tree is shown below. <info lang="ru"> <region id="101541" zoom="13" lat="46.623469" lon="29.910926"> <title>Днестровск</title> </region> <traffic/> <weather climate="1" region="101541"> <source>mb3d</source> <day> <title>Днестровск</title> <country>Молдова</country> <time_zone>Europe/Kiev</time_zone> <summer-time>1</summer-time> <sun_rise>05:30</sun_rise> <sunset>20:23</sunset> <daytime>d</daytime> <date date="2020-05-11T00:00:00Z"> <day weekday="пн">11</day> <month name="мая">5</month> <year>2020</year> <daytime>d</daytime> </date> <day_part typeid="2" type="день"> <weather_type>облачно с прояснениями</weather_type> <weather_code>cloudy</weather_code> <image> https://yastatic.net/weather/i/icons/blueye/24/bkn_d.png </image> <image-v2 size="22x22"> http://yandex.st/weather/v-1/i/icons/22x22/bkn_d_+26.png </image-v2> <image-v3 size="48"> https://yastatic.net/weather/i/icons/blueye/48/bkn_d.png </image-v3> <image_number/> <wind_speed>5.6</wind_speed> <wind_direction id="s">юг</wind_direction> <dampness>33</dampness> <hectopascal>1008</hectopascal> <torr>756</torr> <pressure>756</pressure> <temperature class_name="t26" color="F9EBB9">+26</temperature> <time_zone>Europe/Kiev</time_zone> <observation_time>09:00</observation_time> <observation>2020-05-11T09:00:00</observation> </day_part> <day_part typeid="3" type="вечер"> <image-v2 size="22x22"> http://yandex.st/weather/v-1/i/icons/22x22/bkn_d_+22.png </image-v2> <image-v3 size="30"> https://yastatic.net/weather/i/icons/blueye/30/bkn_d.png </image-v3> <temperature_from class_name="t16" color="F6F3D6">+15</temperature_from> <temperature_to class_name="t24" color="F9EEC0">+23</temperature_to> </day_part> <day_part typeid="4" type="ночь"> <image-v2 size="22x22"> http://yandex.st/weather/v-1/i/icons/22x22/skc_n_+14.png </image-v2> <image-v3 size="30"> https://yastatic.net/weather/i/icons/blueye/30/skc_n.png </image-v3> <temperature class_name="t16" color="F6F3D6">+15</temperature> </day_part> <day_part typeid="1" type="утро"> <image-v2 size="22x22"> http://yandex.st/weather/v-1/i/icons/22x22/ovc_+22.png </image-v2> <image-v3 size="30"> https://yastatic.net/weather/i/icons/blueye/30/ovc.png </image-v3> <temperature_from class_name="t16" color="F6F3D6">+15</temperature_from> <temperature_to class_name="t24" color="F9EEC0">+23</temperature_to> </day_part> <day_part typeid="2" type="день"> <image-v2 size="22x22"> http://yandex.st/weather/v-1/i/icons/22x22/ovc_-ra_+26.png </image-v2> <image-v3 size="30"> https://yastatic.net/weather/i/icons/blueye/30/ovc_-ra.png </image-v3> <temperature_from class_name="t24" color="F9EEC0">+23</temperature_from> <temperature_to class_name="t26" color="F9EBB9">+26</temperature_to> </day_part> <night_short> <temperature class_name="t12" color="F5F2DC">+11</temperature> </night_short> , <tomorrow> <temperature class_name="t26" color="F9EBB9">+26</temperature> </tomorrow> </day> <url slug="dnestrovsk">http://pogoda.yandex.ru/dnestrovsk/</url> </weather> </info>

Тегов <day_part несколько, как мне достать значения?
С не повторяющимися тегами делаю так:
XMLDocument1.DocumentElement.ChildNodes['weather'].ChildNodes['day'].ChildNodes['sunset'].Text;
Помогите пожалуйста.
Ответить с цитированием
  #2  
Старый 11.05.2020, 14:52
Gareth Gareth вне форума
Активный
 
Регистрация: 21.03.2013
Адрес: Приднестровье
Сообщения: 202
Версия Delphi: Delphi 7
Репутация: 10
По умолчанию

Прошу прощения, долго искал инфу по этому поводу.. Нашёл.
Нашёл xml вивер, который натолкнул на мысль.. Нужно было указать номер дочернего тега и в нем уже парсить атрибуты и и тд
XMLDocument1.DocumentElement.ChildNodes['weather'].ChildNodes['day'].ChildNodes[9].AttributeNodes['type'].Text;
Ответить с цитированием
Ответ


Delphi Sources

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать темы
Вы не можете отвечать на сообщения
Вы не можете прикреплять файлы
Вы не можете редактировать сообщения

BB-коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход


Часовой пояс GMT +3, время: 19:27.


 

Сайт

Форум

FAQ

RSS лента

Прочее

 

Copyright © Форум "Delphi Sources" by BrokenByte Software, 2004-2023

ВКонтакте   Facebook   Twitter