I
I
ImVeryStupid2019-08-20 16:55:18
JavaScript
ImVeryStupid, 2019-08-20 16:55:18

What is the best way to parse xml?

there is such xml

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<timedtext format="3">
<head>
<pen id="1" fc="#E5E5E5"/>
<pen id="2" fc="#CCCCCC"/>
<ws id="0"/>
<ws id="1" mh="2" ju="0" sd="3"/>
<wp id="0"/>
<wp id="1" ap="6" ah="20" av="100" rc="2" cc="40"/>
</head>
<body>
<w t="0" id="1" wp="1" ws="1"/>
<p t="0" d="4680" w="1">
<s ac="252">всем</s>
<s t="420" ac="252"> привет</s>
<s t="900" ac="249"> пока</s>
<s t="1230" ac="252"> я</s>
<s t="1380" ac="252"> готовлю</s>
<s t="1680" ac="252"> выпуск</s>
<s t="2220" ac="252"> про</s>
</p>
<p t="2480" d="2200" w="1" a="1"> </p>
<p t="2490" d="4920" w="1">
<s ac="252">один</s>
<s t="419" ac="252"> день</s>
<s t="630" ac="252"> из</s>
<s t="780" ac="252"> жизни</s>
<s t="810" ac="112"> программисты</s>
<s t="1710" ac="249"> где</s>
<s t="1920" ac="252"> все</s>
</p>
<p t="4670" d="2740" w="1" a="1"> </p>
<p t="4680" d="5010" w="1">
<s ac="252">снимаю</s>
<s t="389" ac="252"> на</s>
<s t="480" ac="252"> камеру</s>
<s t="720" ac="252"> как</s>
<s t="990" ac="252"> и</s>
<s t="1199" ac="252"> обещал</s>
<s t="2010" ac="217"> я</s>
<s t="2310" ac="252"> решил</s>
</p>
<p t="7400" d="2290" w="1" a="1"> </p>
<p t="7410" d="4229" w="1">
<s ac="220">сделать</s>
<s t="210" ac="252"> выпуск</s>
<s t="689" ac="248"> в</s>
<s t="990" ac="252"> котором</s>
<s t="1410" ac="252"> покажу</s>
<s t="1800" ac="250"> какие</s>
</p>
<p t="9680" d="1959" w="1" a="1"> </p>
<p t="9690" d="4770" w="1">
<s ac="227">приложил</s>
<s t="540" ac="0"> query</s>
<s t="750" ac="236"> игры</s>
<s t="1050" ac="250"> установлены</s>
<s t="1199" ac="251"> у</s>
<s t="1860" ac="252"> меня</s>
</p>
<p t="11629" d="2831" w="1" a="1"> </p>
<p t="11639" d="5611" w="1">
<s ac="251">на</s>
<s t="271" ac="252"> телефоне</s>
<s t="571" ac="160"> и</s>
<s t="1201" ac="243"> если</s>
<s t="1651" ac="252"> кто</s>
<s t="1861" ac="229"> не</s>
<s t="1981" ac="240"> знает</s>
<s t="2401" ac="245"> то</s>
<s t="2611" ac="252"> в</s>
</p>
<p t="14450" d="2800" w="1" a="1"> </p>
<p t="14460" d="5340" w="1">
<s ac="247">этом</s>
<s t="240" ac="252"> плане</s>
<s t="540" ac="252"> я</s>
<s t="750" ac="252"> фанат</s>
<s t="1320" ac="241"> продукции</s>
<s t="1980" ac="240"> apple</s>
<s t="2280" ac="224"> и</s>
<s t="2640" ac="244"> не</s>
</p>
<p t="17240" d="2560" w="1" a="1"> </p>
<p t="17250" d="5130" w="1">
<s ac="238">потому</s>
<s t="420" ac="241"> что</s>
<s t="690" ac="252"> я</s>
<s t="840" ac="252"> мажор</s>
<s t="1170" ac="252"> телефоны</s>
<s t="1890" ac="252"> на</s>
<s t="2010" ac="252"> android</s>
</p>
<p t="19790" d="2590" w="1" a="1"> </p>
<p t="19800" d="5370" w="1">
<s ac="212">мне</s>
<s t="180" ac="249"> тоже</s>
<s t="540" ac="218"> как</s>
<s t="809" ac="243"> бы</s>
<s t="840" ac="238"> нравится</s>
<s t="1440" ac="236"> просто</s>
<s t="2040" ac="246"> я</s>
<s t="2130" ac="229"> ценю</s>
</p>
<p t="22370" d="2800" w="1" a="1"> </p>
<p t="22380" d="4380" w="1">
<s ac="216">простоту</s>
<s t="600" ac="218"> и</s>
<s t="809" ac="227"> удобность</s>
<s t="1470" ac="236"> айфонов</s>
<s t="2130" ac="147"> а</s>
<s t="2159" ac="204"> вообще</s>
<s t="2639" ac="252"> по</s>
</p>
...
<p t="490940" d="2260" w="1" a="1"> </p>
<p t="490950" d="4200" w="1">
<s ac="252">так</s>
<s t="360" ac="248"> мои</s>
<s t="570" ac="242"> выпуски</s>
<s t="930" ac="240"> хоть</s>
<s t="1260" ac="252"> иногда</s>
<s t="1380" ac="93"> до</s>
<s t="1800" ac="252"> будут</s>
</p>
<p t="493190" d="1960" w="1" a="1"> </p>
<p t="493200" d="5490" w="1">
<s ac="240">появляться</s>
<s t="480" ac="252"> у</s>
<s t="630" ac="252"> вас</s>
<s t="930" ac="252"> на</s>
<s t="1050" ac="252"> главной</s>
<s t="1410" ac="255"> странице</s>
</p>
<p t="495140" d="3550" w="1" a="1"> </p>
<p t="495150" d="16760" w="1">
<s ac="249">youtube</s>
<s t="389" ac="210"> а</s>
<s t="660" ac="156"> еда</s>
<s t="1139" ac="255"> на</s>
<s t="1350" ac="244"> этом</s>
<s t="1769" ac="252"> пока</s>
<s t="2010" ac="221"> все</s>
<s t="2370" ac="238"> удачи</s>
</p>
<p t="498680" d="13230" w="1" a="1"> </p>
<p t="498690" d="13469" w="1">[музыка]</p>
<p t="511900" d="259" w="1" a="1"> </p>
<p t="511910" d="4909" w="1">
<s ac="215">а</s>
</p>
<p t="512149" d="4670" w="1" a="1"> </p>
<p t="512159" d="4660" w="1">[музыка]</p>
</body>
</timedtext>

You need to take all p tags that have s tags inside. Then create an array where the words from the tag s are on the right, and on the left: <p t="493190" + <s t="480"(the value of the p tag is taken and added to the s tag)
how to do this correctly? without heaps

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lynn "Coffee Man", 2019-08-21
@Lynn

https://developer.mozilla.org/en-US/docs/Web/Guide...
DOMParser and XPath

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question