|
// retoor <retoor@molodetz.nl>
|
|
|
|
import "html" for Document
|
|
|
|
var doc = Document.parse("<div><p>A</p><p>B</p><p>C</p></div>")
|
|
|
|
var list = doc.querySelectorAll("p")
|
|
|
|
System.print(list[0].textContent) // expect: A
|
|
System.print(list[1].textContent) // expect: B
|
|
System.print(list[2].textContent) // expect: C
|
|
|
|
System.print(list[0].tagName) // expect: P
|
|
System.print(list[1].tagName) // expect: P
|
|
System.print(list[2].tagName) // expect: P
|
|
|
|
var mixed = Document.parse("<div><span>X</span><a>Y</a><em>Z</em></div>")
|
|
var children = mixed.querySelector("div").children
|
|
System.print(children[0].tagName) // expect: SPAN
|
|
System.print(children[1].tagName) // expect: A
|
|
System.print(children[2].tagName) // expect: EM
|
|
|