You are here: Reference > JavaScript > client-side > xml handling > properties > xmlVersion (XMLDocument)

xmlVersion property (XMLDocument)

Browser support:
Returns the version of the XMLDocument as a string.

Syntax:

object.xmlVersion;
You can find the related objects in the Supported by objects section below.
This property is read-only.

Possible values:

String that specifies the version of the XML.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the xmlVersion property:
Code
ajax.js
news.xml
<head>
    <script type="text/javascript" src="ajax.js"></script>
    
    <script type="text/javascript">
        var httpRequest = null;
        
        function SendRequest () {
            if (!httpRequest) {
                httpRequest = CreateHTTPRequestObject ();   // defined in ajax.js
            }
            if (httpRequest) {          
                    // The requested file must be in the same domain that the page is served from.
                var url = "news.xml";
                httpRequest.open ("GET", url, true);    // async
                httpRequest.onreadystatechange = OnStateChange;
                httpRequest.send (null);
            }
        }

        function OnStateChange () {
            if (httpRequest.readyState == 0 || httpRequest.readyState == 4) {
                if (IsRequestSuccessful (httpRequest)) {    // defined in ajax.js
                    DisplayInfo ();
                }
                else {
                    alert ("Operation failed.");
                }
            }
        }

        function DisplayInfo () {
            var xmlDoc = ParseHTTPResponse (httpRequest);   // defined in ajax.js
            if (!xmlDoc)
                return;

            var message = "";
            message += "Encoding: " + xmlDoc.xmlEncoding + "\n";
            message += "Standalone: " + xmlDoc.xmlStandalone + "\n";
            message += "Version: " + xmlDoc.xmlVersion + "\n";
            alert (message);
        }
    </script>
</head>
<body>
    <button onclick="SendRequest ()">Get information from news.xml</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content