Rendering the AuthorName using the DOMParser to read XML I need to concatenate the LastName and Initials and all of that authors affiliations. Is there a better way or faster way to do this?  I'm very new to working XML in JavaScript.

This is a portion of an XML string that I get back from an API that I parse in JavaScript:

   &lt;AuthorList CompleteYN="Y"&gt;
                &lt;Author ValidYN="Y"&gt;
                    &lt;LastName&gt;Basree&lt;/LastName&gt;
                    &lt;ForeName&gt;Mustafa M&lt;/ForeName&gt;
                    &lt;Initials&gt;MM&lt;/Initials&gt;
                    &lt;AffiliationInfo&gt;
                        &lt;Affiliation&gt;The Cancer Center...&lt;/Affiliation&gt;
                    &lt;/AffiliationInfo&gt;
                &lt;/Author&gt;
                &lt;Author ValidYN="Y"&gt;
                    &lt;LastName&gt;Shinde&lt;/LastName&gt;
                    &lt;ForeName&gt;Neelam&lt;/ForeName&gt;
                    &lt;Initials&gt;N&lt;/Initials&gt;
                    &lt;AffiliationInfo&gt;
                        &lt;Affiliation&gt;The Comprehensive..&lt;/Affiliation&gt;
                    &lt;/AffiliationInfo&gt;
                &lt;/Author&gt;
                &lt;Author ValidYN="Y"&gt;
                    &lt;LastName&gt;Koivisto&lt;/LastName&gt;
                    &lt;ForeName&gt;Christopher&lt;/ForeName&gt;
                    &lt;Initials&gt;C&lt;/Initials&gt;
                    &lt;AffiliationInfo&gt;
                        &lt;Affiliation&gt;Hollings ...&lt;/Affiliation&gt;
                    &lt;/AffiliationInfo&gt;
                    &lt;AffiliationInfo&gt;
                        &lt;Affiliation&gt;Department ...&lt;/Affiliation&gt;
                    &lt;/AffiliationInfo&gt;
                &lt;/Author&gt;
                &lt;Author ValidYN="Y"&gt;
                    &lt;LastName&gt;Cuitino&lt;/LastName&gt;
                    &lt;ForeName&gt;Maria&lt;/ForeName&gt;
                    &lt;Initials&gt;M&lt;/Initials&gt;
                    &lt;AffiliationInfo&gt;
                        &lt;Affiliation&gt;Hollings...&lt;/Affiliation&gt;
                    &lt;/AffiliationInfo&gt;
                    &lt;AffiliationInfo&gt;
                        &lt;Affiliation&gt;Department ..&lt;/Affiliation&gt;
                    &lt;/AffiliationInfo&gt;
                &lt;/Author&gt;
&lt;/AuthorList&gt;


my Code:

      let HTMLContent = ""
      parser = new DOMParser();
      xmlDoc = parser.parseFromString(response.data, "text/xml");

      const AuthorsInfo = xmlDoc.querySelectorAll("Author");

      AuthorsInfo.forEach(a =&gt; {
        let affiliations = "";
        let AuthorName = "";

        for (var i = 0; i &lt; a.children.length; i++) {
          let tt = a.children[i].nodeName;
          let t = a.children[i].textContent;
          if (tt === "AffiliationInfo") {
            affiliations += a.children[i].textContent;
            affiliations += "&lt;br /&gt;&lt;br /&gt;";
          } else if (tt === "LastName") {
            AuthorName = a.children[i].textContent;
          } else if (tt === "Initials") {
            AuthorName += " " + a.children[i].textContent;
            AuthorName += "&lt;br /&gt;&lt;br /&gt;";
          }
        }
        HTMLContent  += AuthorName + " " + affiliations;
      });
Style

Inconsistent use of line ending semi colon

Undeclared variables parser and xmlDoc

Unused code. let t = a.children[i].textContent; t is never used the line should not be there

Poor naming

Capitalisation of variable names. Only if objects to be instanciated via new token, if accronim (eg HTML, XML) or if a constant (optional).
Examples; AuthorsInfo should be authorsInfo,  AuthorName as authorName, xmlDoc as XMLDoc.
Non descripttive names, a, tt, t
Semanticly inacurate names, AuthorsInfo either authorNodes or just authors


Use for of loops rather than for if loops if you do not need the index counter

Use for of loops rather than Array iterators

Function scoped variables should be declared as var and hoisted to the top of the function


Code design
As you have several potential errors in the code (undeclared variables) you should ALWAYS use the directive &quot;use strict&quot; in your code to ensure these types of syntax problems are caught early in the development process.
Always present your code as a function/s. Presenting code as flat global scoped source string is very poor design practice.
Flat code often ends up performing many tasks that should be separated. Writing functions helps you define task roles under clearly named functions.
The parsing of the XML to HTML is more than one task. I suggest you have two functions parseAuthors to extract the author details, and authorsToHTML to create the markup.
Example rewrite
From your code it is unclear as to the nature of the XML. Can authors have no last name, initials, or affiliations. Do authors always have one last name, does the last name always come before the initials. And many more unanswered questions regarding the XML.
The example assumes that the XML given defines the XML.
The example breaks the code into many smaller functions and puts them all together inside a IIF (immediately invoked function). In the real world you would put all the code inside a module.


"use strict";
// As IFF or better as module (No need for use strict if module)
const authors = (() =&gt; {
    const AUTHORS = "Author"; 
    const AFFILIATION = "AffiliationInfo";
    const LAST_NAME = "LastName";
    const INITIALS = "Initials";
    const SEP = "&lt;br/&gt;&lt;br/&gt;";
    const nodeTxt = (node, name) =&gt; (name ? node.querySelector(name) : node).textContent;
    
    function Author(authorNode) {
        const author = {
            lastName: nodeTxt(authorNode, LAST_NAME),
            initials: nodeTxt(authorNode, INITIALS),
            affiliations: []
        }
        for (const affNode of authorNode.querySelectorAll(AFFILIATION)) {
            author.affiliations.push(nodeTxt(affNode));
        }
        return author;
    }

    return {
        parse(XMLString) {
            const authors = [];
            const authorNodes = new DOMParser()
                .parseFromString(XMLString, "text/xml")
                .querySelectorAll("Author");
            for (const authorNode of authorNodes) { authors.push(Author(authorNode)) }
            return authors;
        },
        toHTML(authors) {
            var markup = "";
            for (const author of authors) {
                markup += author.lastName + " " + author.initials + SEP;
                markup += " " + author.affiliations.join(SEP) + SEP;
            }
            return markup;
        },
    };
})();
document.body.innerHTML = authors.toHTML(authors.parse(getXML()));





function getXML() { return `&lt;AuthorList CompleteYN="Y"&gt;
&lt;Author ValidYN="Y"&gt;
    &lt;LastName&gt;Basree&lt;/LastName&gt;
    &lt;ForeName&gt;Mustafa M&lt;/ForeName&gt;
    &lt;Initials&gt;MM&lt;/Initials&gt;
    &lt;AffiliationInfo&gt;
        &lt;Affiliation&gt;The Cancer Center...&lt;/Affiliation&gt;
    &lt;/AffiliationInfo&gt;
&lt;/Author&gt;
&lt;Author ValidYN="Y"&gt;
    &lt;LastName&gt;Shinde&lt;/LastName&gt;
    &lt;ForeName&gt;Neelam&lt;/ForeName&gt;
    &lt;Initials&gt;N&lt;/Initials&gt;
    &lt;AffiliationInfo&gt;
        &lt;Affiliation&gt;The Comprehensive..&lt;/Affiliation&gt;
    &lt;/AffiliationInfo&gt;
&lt;/Author&gt;
&lt;Author ValidYN="Y"&gt;
    &lt;LastName&gt;Koivisto&lt;/LastName&gt;
    &lt;ForeName&gt;Christopher&lt;/ForeName&gt;
    &lt;Initials&gt;C&lt;/Initials&gt;
    &lt;AffiliationInfo&gt;
        &lt;Affiliation&gt;Hollings ...&lt;/Affiliation&gt;
    &lt;/AffiliationInfo&gt;
    &lt;AffiliationInfo&gt;
        &lt;Affiliation&gt;Department ...&lt;/Affiliation&gt;
    &lt;/AffiliationInfo&gt;
&lt;/Author&gt;
&lt;Author ValidYN="Y"&gt;
    &lt;LastName&gt;Cuitino&lt;/LastName&gt;
    &lt;ForeName&gt;Maria&lt;/ForeName&gt;
    &lt;Initials&gt;M&lt;/Initials&gt;
    &lt;AffiliationInfo&gt;
        &lt;Affiliation&gt;Hollings...&lt;/Affiliation&gt;
    &lt;/AffiliationInfo&gt;
    &lt;AffiliationInfo&gt;
        &lt;Affiliation&gt;Department ..&lt;/Affiliation&gt;
    &lt;/AffiliationInfo&gt;
&lt;/Author&gt;
&lt;/AuthorList&gt;`
};