HTML::Object::DOM::Implementation - HTML Object DOM Implementation
use HTML::Object::DOM::Implementation; my $impl = HTML::Object::DOM::Implementation->new || die( HTML::Object::DOM::Implementation->error, "\n" );
v0.2.0
The Implementation interface represents an object providing methods which are not dependent on any particular document. Such an object is returned by the "implementation" in HTML::Object::DOM::Document property.
Implementation
There are no properties
Provided with a namespace URI (which could be an empty string) and a qualified name for the top element, which should be html and optionally a document type definition object and this creates and returns a document object.
html
Normally, this method is used to create an XML document, but we do not support XML, so this is basically an alias for "createHTMLDocument"
The namespaceURI argument is completely ignored, so do not bother and the qualified name can only be html.
Example:
my $doc = $doc->implementation->createDocument( $namespaceURI, $qualifiedNameStr, $documentType_object ); my $doc = $doc->implementation->createDocument( '', 'html' ); my $body = $doc->createElement( 'body' ); $body->setAttribute( 'id', 'abc' ); $doc->documentElement->appendChild( $body ); say( $doc->getElementById( 'abc') ); # [object HTMLBodyElement]
See also Mozilla documentation
Provided with a qualified name, which should be html and an optional public id and system id, both of which are ignored, and this creates and returns a document type object.
my $doctype = $doc->implementation->createDocumentType( 'html', $publicId, $systemId ); my $dt = $doc->implementation->createDocumentType( 'svg:svg', '-//W3C//DTD SVG 1.1//EN', 'http://www->w3.org/Graphics/SVG/1.1/DTD/svg11.dtd' ); my $d = $doc->implementation->createDocument( 'http://www->w3.org/2000/svg', 'svg:svg', $dt ); say( $d->doctype->publicId); # -//W3C//DTD SVG 1.1//EN
Creates and returns an HTML Document.
# Assuming $title is "Demo" my $newDoc = $doc->implementation->createHTMLDocument( $title );
Result:
<!DOCTYPE html> <html> <head><title>Demo</title></head> <body></body> </html>
This always returns true.
Its original purpose is to return a boolean value indicating if a given feature is supported or not. However, this function has been unreliable and kept for compatibility purpose alone: except for SVG-related queries.
my $flag = $doc->implementation->hasFeature( $feature, $version );
Jacques Deguest <jack@deguest.jp>
Mozilla documentation
Copyright(c) 2022 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.
To install HTML::Object, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTML::Object
CPAN shell
perl -MCPAN -e shell install HTML::Object
For more information on module installation, please visit the detailed CPAN module installation guide.