how to access non-standard javascript properties

1

Hello, I make an xml request, and I get a tag named item, with some unconventional attributes

$.ajax({
    type:"GET",
    dataType: 'text',
    url : "requests/playlist_jstree.xml",
    success: function(retorno){
        parser = new DOMParser();
        xmlDoc = parser.parseFromString(retorno,"text/xml");
        var lista=xmlDoc.getElementById("plid_2").getElementsByTagName("item");
        console.log(xmlDoc.getElementById("plid_5").uri);
    }, 
    error: function(e){

    }
});

This plid_5 is inside the plid_2, I could have accessed it so too:

console.log(lista[0].uri

But neither can access this attribute called uri, in fact the only attribute that works is the id, the other attributes do not access, how do I access the value of these attributes?

    
asked by anonymous 29.03.2017 / 11:28

1 answer

0

If you refer to attributes represented in XML, you access them similarly as in the current class HTMLElement .

let elem = xmlDoc.getElementById 'plid_5'

console.log(
    elem.attributes.uri.value,
    elem.attributes[índice].value,
    elem.getAttribute 'uri'
)
    
29.03.2017 / 14:37