0

I'm having a few issues reading the height and width attributes about an image that has been processed into individual tiles, from an xml file created during this process.

The contents of this file are as such:

<IMAGE_PROPERTIES WIDTH="61504" HEIGHT="25408" NUMTILES="32233" NUMIMAGES="1" VERSION="1.8" TILESIZE="256" />

To read the xml file I have used the following code:

<!-- language: lang-js -->

var xhr = new XMLHttpRequest();
xhr.open('GET', path, true);
xhr.timeout = 2000; 
xhr.onload = function () {
    var xmlDoc = this.responseXML;
    console.log(xmlDoc);
    var x = xmlDoc.getElementsByTagName("IMAGE_PROPERTIES")[0];
    console.log(x);
};

<!-- end snippet -->

How do I now access the height and width attributes?

1

1 Answer 1

0

Use the getAttribute function on the element (x in your case) that you found. See https://www.w3schools.com/xml/met_element_getattribute.asp

Sign up to request clarification or add additional context in comments.

1 Comment

I get the message "x.getAttribute is not a function at XMLHttpRequest.xhr.onload"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.