I build my XML with my base XML like this:
$(xml).find('PARENT').find('CHILDREN').each(function(i){
outputstr += '<lorem id="">'
})
now the Object "parent" exists a few times in every XML I read, I want to count up the ID Attribute to every lorem build.
then my output XML should look like this:
<lorem id="1"/>
<lorem id="2"/>
<lorem id="3"/>
how do I count up each time a Element was build
2
Answers
You can use a template literal to substitute
i
into the output.You could combine the parent and child selectors into one
$.fn.find
call.As mentioned, you can use the
DomParser
instead of jQuery. Parsing XML should not require pulling in the jQuery library.