I am facing the following problem:
I am given a XML string and a message (string) I need a function that can parse the XML string and return an array of ids for the XML tags (id="x") in which the message is present.
I can only use JavaScript for this.
function getIdByMessage(xml, message) {
// problem to solve
}
var xml = `
<test>blabla</test>
<otherstuff>MoreStuff</otherstuff>
<message-not-relevant>Not relevant</message-not-relevant>
<entry id="4">Function Message<entry>
<otherstuff>MoreStuff</otherstuff>
<message-not-relevant>Not relevant</message-not-relevant>
<entry id="3">Function Message<entry>
<otherstuff>MoreStuff</otherstuff>
<message-not-relevant>Not relevant</message-not-relevant>
`
getIdByMessage(xml, 'Function Message'); // should return [4, 3];