read XML with JS
I need some kind way if reading.parsing XML files with JS. I need toknow how to: -select the first, second etc. child -get attributes of an element -get value of element -how many elements exist called:““ I would prefer jQuery
JaScript thanks, I have still a few unanswerd things how do I get the first, second, etc. if there is more than on title, for example How do I get an elements child WITH XML syntax, for exmaple get album would result in <title>Dirrty><year><2011></year> How many elements exist as a child of an element, for example album would result in 2 Thank You!
Today will be used mostly json which is easier to parsing. If you need xml you can do that i.e. as follows: let myxml = '<?xml version="1.0" encoding="ISO-8859-1"?>' + '<artists>' + '<artist name="Christina">' + '<albums>' + '<album>' + '<title>Dirrty</title>' + '<year>2011</year>' + '</album>' + '</albums>' + '</artist>' + '</artists>'; let myParser = new DOMParser(); let xmlDOM = myParser.parseFromString(myxml, 'text/xml'); let artist = xmlDOM.querySelector('artist'); console.log(artist.getAttribute('name')); // "Christina" console.log(artist.querySelector('title').textContent); // "Dirrty" console.log(artist.querySelector('year').textContent); // 2011
I have made a calculator in which my % (Percentage) not work correctly for 100%50 or 100%20.
Python palindrome challenge.