dom :: XMLStartTag :: data
PCDATA
or CDATA
var code = """
<?xml version="1.0" encoding="us-ascii"?>
<animal>
<cat/>
<tiger>This is a white tiger!</tiger>
<cat/>
</animal>"""
var xml = code.to_xml
assert xml["animal"].first["tiger"].first.as(XMLStartTag).data == "This is a white tiger!"
# Content of this XML tag held within a `PCDATA` or `CDATA`
#
# ~~~
# var code = """
# <?xml version="1.0" encoding="us-ascii"?>
# <animal>
# <cat/>
# <tiger>This is a white tiger!</tiger>
# <cat/>
# </animal>"""
#
# var xml = code.to_xml
# assert xml["animal"].first["tiger"].first.as(XMLStartTag).data == "This is a white tiger!"
# ~~~
fun data: nullable String
do
for child in children do
if child isa PCDATA then return child.content
if child isa CDATA then return child.content
end
return null
end
lib/dom/dom.nit:47,2--68,4