HTML5::Node
A Node consists of a NodeType and some data (tag name for element nodes,
content for text) and are part of a tree of Nodes. Element nodes may also
have a namespace and contain an array of Attribute. data is unescaped, so
that it looks like "a<b" rather than "a<b". For element nodes, data_atom
is the atom for data, or zero if data is not a known tag name.
An empty namespace implies a "http://www.w3.org/1999/xhtml" namespace. Similarly, "math" is short for "http://www.w3.org/1998/Math/MathML", and "svg" is short for "http://www.w3.org/2000/svg".
Constructors
Instance methods
append_child adds a node as child of self. It will raise exception if c already has a parent or siblings
returns the attribute value with specified name. if current node is element? it returns
the inner text or else it will scan through node attributes and returns the value of attribute matching the name
returns "" if no attribute is found.
clone returns a new node with the same type, data and attributes. The clone has no parent, no siblings and no children
Searches this node for CSS Selector expression. Returns all of the matched HTML5::Node
insert_before inserts a new_child as a child of self, immediately before old_child in the sequence of self's children. old child may be nil, in which case new child is appended to the end of self's children.
It will raise exception if new child already has a parent or sibling
remove_child remove a node c that is a child of self. Afterwards, c will have no parent and no siblings.
It will raise exception if c's parent is not this node
render renders the parse tree node to the given IO writer.
Rendering is done on a 'best effort' basis: calling parse on the output of
render will always result in something similar to the original tree, but it
is not necessarily an exact clone unless the original tree was 'well-formed'.
'Well-formed' is not easily specified; the HTML5 specification is
complicated.
Calling parse on arbitrary input typically results in a 'well-formed' parse
tree. However, it is possible for Parse to yield a 'badly-formed' parse tree.
For example, in a 'well-formed' parse tree, no element is a child of
another element: parsing "" results in two sibling elements.
Similarly, in a 'well-formed' parse tree, no element is a child of a