XML DOM inputEncoding Attribute

Document Object Reference Manual

Definition and Usage

The inputEncoding attribute can return the encoding used for the document (at parsing time).

Syntax:

documentObject.inputEncoding

Example

In all examples, we will use the XML file books.xml, and JavaScript functions loadXMLDoc().

The following code snippet can display XML encoding, standalone attribute, and the XML version of the document:

xmlDoc=loadXMLDoc("/example/xdom/books.xml");
document.write("XML encoding: " + xmlDoc.xmlEncoding);
document.write("<br />");
document.write("XML standalone: " + xmlDoc.xmlStandalone);
document.write("<br />");
document.write("XML version: " + xmlDoc.xmlVersion);
document.write("<br />");
document.write("Encoding when parsing: " + xmlDoc.inputEncoding);

Output:

XML encoding: ISO-8859-1
XML standalone: false
XML version: 1.0
Encoding when parsing: ISO-8859-1

Document Object Reference Manual