|
// retoor <retoor@molodetz.nl>
|
|
|
|
import "html" for Document
|
|
|
|
var doc = Document.parse("<div id='first'>One</div><div id='second'>Two</div><div>No ID</div>")
|
|
|
|
var first = doc.getElementById("first")
|
|
System.print(first != null) // expect: true
|
|
System.print(first.textContent) // expect: One
|
|
|
|
var second = doc.getElementById("second")
|
|
System.print(second != null) // expect: true
|
|
System.print(second.textContent) // expect: Two
|
|
|
|
var notFound = doc.getElementById("nonexistent")
|
|
System.print(notFound == null) // expect: true
|
|
|
|
var nested = Document.parse("<div><span id='inner'>Nested</span></div>")
|
|
var inner = nested.getElementById("inner")
|
|
System.print(inner != null) // expect: true
|
|
System.print(inner.tagName) // expect: SPAN
|
|
|