Name
SPVM::Eg::Node - HTML Nodes, Attributes, Text.
Description
The Eg::Node class in SPVM has methods to manipulate HTML nodes, attributes, text.
Usage
use Eg::Node;
{
my $text = Eg->text("foo");
my $text_string = $text->text->to_string
}
{
my $ul = Eg->ul(
[
Eg->li([Eg->text("1")]),
Eg->li([Eg->text("2")]),
Eg->li([Eg->text("3")]),
],
{class => "foo bar", id => "foo", style => "color:red"}
);
# 1
my $li1 = $ul->nodes->get(0)->(Eg::Node);
my $text_string1 = $li1->nodes->get(0)->(Eg::Node)->text->to_string;
# 2
my $li2 = $ul->nodes->get(1)->(Eg::Node);
my $text_string2 = $li2->nodes->get(0)->(Eg::Node)->text->to_string;
# color:red
my $attr = $div->attributes->get_string("style")
}
Enumerations
Type Constant Values
The constant values for the "type" field.
enum {
TYPE_ELEMENT_NODE = 1,
TYPE_ATTRIBUTE_NODE = 2,
TYPE_TEXT_NODE = 3,
TYPE_CDATA_SECTION_NODE = 4,
TYPE_PROCESSING_INSTRUCTION_NODE = 7,
TYPE_COMMENT_NODE = 8,
TYPE_DOCUMENT_NODE = 9,
TYPE_DOCUMENT_TYPE_NODE = 10,
TYPE_DOCUMENT_FRAGMENT_NODE = 11,
}
Fields
type
has type : ro int;
nodes
has nodes : ro List of Eg::Node;
attributes
has attributes : ro Hash of string;
tag_name
has tag_name : ro string;
text
has text : ro StringBuffer;
Class Methods
new_text
static method new_text : Eg::Node ($text : string);
Copyright & License
Copyright (c) 2023 Yuki Kimoto
MIT License