class LibXML::XML::Dtd

The XML::Dtd class is used to prepare DTD’s for validation of xml documents.

DTDs can be created from a string or a pair of public and system identifiers. Once a Dtd object is instantiated, an XML document can be validated by the XML::Document#validate method providing the XML::Dtd object as parameeter. The method will raise an exception if the document is not valid.

Basic usage:

# parse DTD
dtd = XML::Dtd.new(<<EOF)
<!ELEMENT root (item*) >
<!ELEMENT item (#PCDATA) >
EOF

# parse xml document to be validated
instance = XML::Document.file('instance.xml')

# validate
instance.validate(dtd)