1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # This file is free software, which comes along with NIT. This software is
4 # distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
5 # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
6 # PARTICULAR PURPOSE. You can modify it is you want, provided this header
7 # is kept unaltered, and a notification of the changes is added.
8 # You are allowed to redistribute it and sell it, alone or is a part of
18 # The `XMLTag` children with the `tag_name`
22 # <?xml version="1.0" encoding="us-ascii"?>
25 # <tiger>This is a white tiger!</tiger>
29 # var xml = code.to_xml
30 # assert xml["animal"].length == 1
31 # assert xml["animal"].first["cat"].length == 2
33 fun [](tag_name
: String): Array[XMLEntity]
35 var res
= new Array[XMLEntity]
36 for child
in children
do
37 if child
isa XMLTag and child
.tag_name
== tag_name
then
45 redef class XMLStartTag
47 # Content of this XML tag held within a `PCDATA` or `CDATA`
51 # <?xml version="1.0" encoding="us-ascii"?>
54 # <tiger>This is a white tiger!</tiger>
58 # var xml = code.to_xml
59 # assert xml["animal"].first["tiger"].first.as(XMLStartTag).data == "This is a white tiger!"
63 for child
in children
do
64 if child
isa PCDATA then return child
.content
65 if child
isa CDATA then return child
.content