The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

HTML::Object::Attribute - HTML Object Element Attribute Class

SYNOPSIS

    use HTML::Object::Attribute;
    my $attr = HTML::Object::Attribute->new( 'id' );
    $attr->value = "hello";

VERSION

    v0.2.0

DESCRIPTION

This class represent an element attribute. it is used as part of HTML::Object, and also contains methods to interface with HTML::Object::XPath

CONSTRUCTOR

new

Creates a new HTML::Object::Attribute objects.

It may also take an hash like arguments, that also are method of the same name.

    my $attr = HTML::Object::Attribute->new( 'id' );
    # or
    my $attr = HTML::Object::Attribute->new( name => 'id' );

PROPERTIES

nodeValue

This returns or sets the value of the current node.

For document, element or collection, this returns undef and for attribute, text or comment, this returns the objct value.

See for more information

METHODS

element

Returns the HTML::Object::Element object to which this attribute belongs.

getAttributes

Returns an array object of the related element's attributes as HTML::Object::Attribute objects.

getLocalName

Returns the attribute name.

getName

Returns the attribute name.

getNextSibling

Returns the next attribute object, or undef.

getParentNode

Returns the parent HTML::Object::Element object.

getPreviousSibling

Returns the previous attribute object, or undef.

getValue

Returns the attribute value.

isAttributeNode

Always returns true.

is_inside

Provided with an HTML::Object::Element and this will return true if this attribute is inside it, or false otherwise.

lineage

Add the parent element to our lineage. See "lineage" in HTML::Object::Element

localName

Read-only.

A string representing the local part of the qualified name of the attribute.

This is the same as "getName", because this interface does not use xml prefix

See for more information

name

Set or get the attribute name.

Normally, under JavaScript, this is read-only, but under perl you can change it. Still be careful.

See for more information

namespaceURI

Read-only

A string representing the URI of the namespace of the attribute, or undef if there is no namespace.

This actually always return undef, because this interface does not use xml prefix

See for more information

nodeValue

This returns or sets the value of the current element.

See for more information

ownerElement

Returns the element object to which this attribute object belongs.

See for more information

prefix

Read-only.

This always return undef, because this interface does not use xml prefix

Normally, under JavaScript, this would return a string representing the namespace prefix of the attribute, or c<undef> if a namespace without prefix or no namespace are specified.

See for more information

rank

Set or get the attribute rank. This returns a number object

string_value

This is an alias for "value"

to_boolean

Returns the attribute value as a boolean

to_literal

Returns the attribute value as a litteral

to_number

Returns the attribute value as a number

toString

Returns a stringification of this attribute such as attribute="value"

value

Set or get the value of this attribute as a scalar object. For example:

    $attr->value( "hello" );

See for more information

AUTHOR

Jacques Deguest <jack@deguest.jp>

SEE ALSO

HTML::Object, HTML::Object::Attribute, HTML::Object::Boolean, HTML::Object::Closing, HTML::Object::Collection, HTML::Object::Comment, HTML::Object::Declaration, HTML::Object::Document, HTML::Object::Element, HTML::Object::Exception, HTML::Object::Literal, HTML::Object::Number, HTML::Object::Root, HTML::Object::Space, HTML::Object::Text, HTML::Object::XQuery

https://developer.mozilla.org/en-US/docs/Web/API/Attr

Mozilla reference

W3C standard on attributes

COPYRIGHT & LICENSE

Copyright (c) 2021 DEGUEST Pte. Ltd.

All rights reserved

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.