XML DOM inputEncoding అంశం

నిర్వచనం మరియు ఉపయోగం

inputEncoding అంశం డాక్యుమెంట్ కొరకు ఉపయోగించే కోడింగ్‌ను (పరిశీలన సమయంలో) తిరిగి ఇస్తుంది.

విధానం

documentObject.inputEncoding

ఉదాహరణ

ఈ కోడు "books.xml" ని xmlDoc లోకి లోడ్ చేస్తుంది మరియు డాక్యుమెంట్ యొక్క XML కోడింగ్‌ను, standalone అంశాన్ని మరియు XML వెర్షన్‌ను ప్రదర్శిస్తుంది:

var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
   if (this.readyState == 4 && this.status == 200) {
       myFunction(this);
   }
};
xhttp.open("GET", "books.xml", true);
xhttp.send();
function myFunction(xml) {
    var xmlDoc = xml.responseXML;
    document.getElementById("demo").innerHTML =
    "XML encoding: " + xmlDoc.xmlEncoding +
    "<br>XML standalone: " + xmlDoc.xmlStandalone +
    "<br>XML version: " + xmlDoc.xmlVersion +
    "<br>Encoding used when parsing: " + xmlDoc.inputEncoding;
}

亲自试一试