---
name: "Apache::MimeXML"
section: "3pm"
platform: "linux"
package: "axkit"
version: "1.5-1"
release: "Debian 3.0 (Woody)"
platforms: ["linux"]
url: "https://new.carta.tech/Apache::MimeXML"
---

# Apache::MimeXML(3pm)

Apache::MimeXML - mod\_perl mime encoding sniffer for XML files Simply add this line to srm.conf or httpd.conf:

```
  PerlTypeHandler +Apache::MimeXML
```

Alternatively add it only for certain files or directories using the standard Apache methods. There is about a 30% slowdown for files using this module, so you probably want to restrict it to certain XML locations only. An XML Content-Type sniffer. This module reads the encoding attribute in the xml declaration and returns an appropriate content-type heading. If no encoding declaration is found it returns utf-8 or utf-16 depending on the specific encoding. There are a few small configuration options for this module, allowing you to set various parameters.\
 **XMLMimeType** Allows you to set the mime type for XML files:

```
    PerlSetVar XMLMimeType application/xml
```

That changes the mime type from the default text/xml to application/xml. You can use this on a per-directory basis.\
 **XMLUtf16EncodingBE** Allows you to set the encoding of big-endian (read: normal)  utf 16 (unicode) documents. The default is 'utf-16'

```
    PerlSetVar XMLUtf16EncodingBE utf-16-be
```

**XMLUtf16EncodingLE** Allows you to set the encoding of little-endian utf-16 encoded documents. The default is 'utf-16-le'

```
    PerlSetVar XMLUtf16EncodingLE utf-16-wierd
```

If you want to use Apache::MimeXML's detection routines from other modules, you can manually call the *check\_for\_xml()* or *check\_for\_xml\_file()* functions yourself. *check\_for\_xml\_file()* takes a single parameter of a filename, and *check\_for\_xml()* can take either an XML string, or an open filehandle of some sort. The functions returns the encoding if they find that  the parameter contains XML, otherwise they return nothing:

```
    my $encoding;
    if ($encoding =
        Apache::MimeXML::check_for_xml_file($filename)) {
        print "$filename is XML in the $encoding encoding\n";
    }
```

Matt Sergeant matt@sergeant.org This module is distributed under the same terms as perl itself
