UNPKG

xml-utils

Version:

Parse XML without Blowing Up Your Bundle Size

12 lines (10 loc) 383 B
import findTagByName from "./find-tag-by-name.mjs"; export default function removeTagsByName(xml, tagName, options) { const debug = (options && options.debug) || false; let tag; while ((tag = findTagByName(xml, tagName, { debug }))) { xml = xml.substring(0, tag.start) + xml.substring(tag.end); if (debug) console.log("[xml-utils] removed:", tag); } return xml; }