parsování xml a výpis xml
parent
0e5089afd6
commit
0ade9c4503
@ -0,0 +1,8 @@
|
|||||||
|
class Comment {
|
||||||
|
constructor(start, end, text, fulltext) {
|
||||||
|
this.start = start;
|
||||||
|
this.end = end;
|
||||||
|
this.text = text;
|
||||||
|
this.fulltext = fulltext;
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,20 @@
|
|||||||
class Model {
|
class Model {
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
|
parseXML(xml) {
|
||||||
|
let parser = new DOMParser();
|
||||||
|
let xmlDoc = parser.parseFromString(xml, "text/xml");
|
||||||
|
|
||||||
|
this.comments = [];
|
||||||
|
|
||||||
|
let comment = xmlDoc.getElementsByTagName("comment");
|
||||||
|
for (let i = 0; i < comment.length; i++) {
|
||||||
|
let start = comment[i].getElementsByTagName("start")[0].innerHTML;
|
||||||
|
let end = comment[i].getElementsByTagName("end")[0].innerHTML;
|
||||||
|
let text = comment[i].getElementsByTagName("text")[0].innerHTML;
|
||||||
|
let fulltext = comment[i].getElementsByTagName("fulltext")[0].innerHTML;
|
||||||
|
|
||||||
|
this.comments.push(new Comment(start, end, text, fulltext));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<video id="video">
|
||||||
|
<comment>
|
||||||
|
<start>12</start>
|
||||||
|
<end>15</end>
|
||||||
|
<text>Toto je testovací poznámka</text>
|
||||||
|
<fulltext>Toto je dlouhý text, který bude zobrazen ve videu dole a bude moci obsahovat markdown</fulltext>
|
||||||
|
|
||||||
|
</comment>
|
||||||
|
<comment>
|
||||||
|
<start>19</start>
|
||||||
|
<end>25</end>
|
||||||
|
<text>Toto je testovací poznámka</text>
|
||||||
|
<fulltext>Toto je dlouhý text, který bude zobrazen ve videu dole a bude moci obsahovat markdown</fulltext>
|
||||||
|
|
||||||
|
</comment>
|
||||||
|
</video>
|
Loading…
Reference in New Issue