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?

Gecko29
  • 179
  • 1
  • 2
  • 12
  • 1
    Does this answer your question? [reading XML attributes in javascript](https://stackoverflow.com/questions/15329878/reading-xml-attributes-in-javascript) – Heretic Monkey Feb 18 '20 at 16:03

1 Answers1

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

William Walseth
  • 2,803
  • 1
  • 23
  • 25