XML::LibXML::Dtd(3)
π XML::LibXML::Dtd π
okay bestie, welcome to XML::LibXML::Dtd β the XML::LibXML DTD Handling page, and yes it's giving very niche very powerful and we're gonna get through it together π«Ά
β¨ SYNOPSIS β¨
like, here's the vibe up front, no gatekeeping:
use XML::LibXML;
$dtd = XML::LibXML::Dtd->new($public_id, $system_id);
$dtd = XML::LibXML::Dtd->parse_string($dtd_str);
$publicId = $dtd->getName();
$publicId = $dtd->publicId();
$systemId = $dtd->systemId();
that's the whole lineup, she's compact, she's iconic π
πΈ DESCRIPTION πΈ
so this class holds a DTD. that's her whole job and she does it well. you can parse a DTD from either a string, or from an external SYSTEM identifier. pick your fighter π
ngl there's no support available as yet for parsing from a filehandle. like, not yet. we said what we said π
and here's the part that makes her so powerful: XML::LibXML::Dtd is a sub-class of XML::LibXML::Node, so literally every method that works on nodes is available to Dtd objects β especially toString() β¨ iykyk.
π METHODS π
π new
$dtd = XML::LibXML::Dtd->new($public_id, $system_id);
this one parses a DTD straight from the system identifier and hands you back a DTD object that you can pass right into $doc->is_valid() or $doc->validate(). slay.
my $dtd = XML::LibXML::Dtd->new(
"SOME // Public / ID / 1.0",
"test.dtd"
);
my $doc = XML::LibXML->new->parse_file("test.xml");
$doc->validate($dtd);
look at her go. valid file, validated doc, main character energy fr fr π¦
π§ parse_string
$dtd = XML::LibXML::Dtd->parse_string($dtd_str);
same as new() above, except here you get to parse a DTD from a string instead. cute, convenient, obsessed.
heads up though β parsing from a string may fail if the DTD contains external parametric-entity references with relative URLs. so like, know that before you come for her π
π getName
$publicId = $dtd->getName();
returns the name of DTD β meaning the name immediately following the DOCTYPE keyword. periodt.
β publicId
$publicId = $dtd->publicId();
returns the public identifier of the external subset π
π systemId
$systemId = $dtd->systemId();
returns the system identifier of the external subset. two little identifier getters, both living their truth πΈ
π AUTHORS π
the icons behind all this:
- Matt Sergeant
- Christian Glahn
- Petr Pajas
π VERSION π
2.0213 β yes, she's got a version number, she's official.
π COPYRIGHT π
- 2001-2007, AxKit.com Ltd.
- 2002-2006, Christian Glahn.
- 2006-2009, Petr Pajas.
π«Ά LICENSE π«Ά
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. iconic behavior, honestly.
and that's the whole page bestie π this was XML::LibXML::Dtd(3) from the User Contributed Perl Documentation, perl v5.42.2, dated 2026-05-25. go validate something, you've got this πβ¨
π¦ where this page comes from
- fedora 43: perl-XML-LibXML 1:2.0213-1.fc43 Β· (GPL-1.0-or-later OR Artistic-1.0-Perl) AND MIT
- fedora 44: perl-XML-LibXML 1:2.0213-1.fc44 Β· (GPL-1.0-or-later OR Artistic-1.0-Perl) AND MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms