{
    "mode": "perldoc",
    "parameter": "XML::SAX::ParserFactory",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/XML%3A%3ASAX%3A%3AParserFactory/json",
    "generated": "2026-06-10T17:54:15Z",
    "synopsis": "use XML::SAX::ParserFactory;\nuse XML::SAX::XYZHandler;\nmy $handler = XML::SAX::XYZHandler->new();\nmy $p = XML::SAX::ParserFactory->parser(Handler => $handler);\n$p->parseuri(\"foo.xml\");\n# or $p->parsestring(\"<foo/>\") or $p->parsefile($fh);",
    "sections": {
        "NAME": {
            "content": "XML::SAX::ParserFactory - Obtain a SAX parser\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use XML::SAX::ParserFactory;\nuse XML::SAX::XYZHandler;\nmy $handler = XML::SAX::XYZHandler->new();\nmy $p = XML::SAX::ParserFactory->parser(Handler => $handler);\n$p->parseuri(\"foo.xml\");\n# or $p->parsestring(\"<foo/>\") or $p->parsefile($fh);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "XML::SAX::ParserFactory is a factory class for providing an application with a Perl SAX2 XML\nparser. It is akin to DBI - a front end for other parser classes. Each new SAX2 parser installed\nwill register itself with XML::SAX, and then it will become available to all applications that\nuse XML::SAX::ParserFactory to obtain a SAX parser.\n\nUnlike DBI however, XML/SAX parsers almost all work alike (especially if they subclass\nXML::SAX::Base, as they should), so rather than specifying the parser you want in the call to\n\"parser()\", XML::SAX has several ways to automatically choose which parser to use:\n\n*   $XML::SAX::ParserPackage\n\nIf this package variable is set, then this package is \"require()\"d and an instance of this\npackage is returned by calling the \"new()\" class method in that package. If it cannot be\nloaded or there is an error, an exception will be thrown. The variable can also contain a\nversion number:\n\n$XML::SAX::ParserPackage = \"XML::SAX::Expat (0.72)\";\n\nAnd the number will be treated as a minimum version number.\n\n*   Required features\n\nIt is possible to require features from the parsers. For example, you may wish for a parser\nthat supports validation via a DTD. To do that, use the following code:\n\nuse XML::SAX::ParserFactory;\nmy $factory = XML::SAX::ParserFactory->new();\n$factory->requirefeature('http://xml.org/sax/features/validation');\nmy $parser = $factory->parser(...);\n\nAlternatively, specify the required features in the call to the ParserFactory constructor:\n\nmy $factory = XML::SAX::ParserFactory->new(\nRequiredFeatures => {\n'http://xml.org/sax/features/validation' => 1,\n}\n);\n\nIf the features you have asked for are unavailable (for example the user might not have a\nvalidating parser installed), then an exception will be thrown.\n\nThe list of known parsers is searched in reverse order, so it will always return the last\ninstalled parser that supports all of your requested features (Note: this is subject to\nchange if someone comes up with a better way of making this work).\n\n*   SAX.ini\n\nParserFactory will search @INC for a file called SAX.ini, which is in a simple format:\n\n# a comment looks like this,\n; or like this, and are stripped anywhere in the file\nkey = value # SAX.in contains key/value pairs.\n\nAll whitespace is non-significant.\n\nThis file can contain either a line:\n\nParserPackage = MyParserModule (1.02)\n\nWhere MyParserModule is the module to load and use for the parser, and the number in\nbrackets is a minimum version to load.\n\nOr you can list required features:\n\nhttp://xml.org/sax/features/validation = 1\n\nAnd each feature with a true value will be required.\n\n*   Fallback\n\nIf none of the above works, the last parser installed on the user's system will be used. The\nXML::SAX package ships with a pure perl XML parser, XML::SAX::PurePerl, so that there will\nalways be a fallback parser.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Matt Sergeant, matt@sergeant.org\n",
            "subsections": []
        },
        "LICENSE": {
            "content": "This is free software, you may use it and distribute it under the same terms as Perl itself.\n",
            "subsections": []
        }
    },
    "summary": "XML::SAX::ParserFactory - Obtain a SAX parser",
    "flags": [],
    "examples": [],
    "see_also": []
}