src/index.js
function extract (xml, tagName, attributeName) {
  if (!Array.isArray(tagName)) {
    tagName = [tagName]
  }

  var found = null
  var tagFound = null
  for (var i = 0; i < tagName.length; i++) {
    // without attributes
    found = new RegExp(`<${tagName[i]}\\s*>(.+?)</${tagName[i]}>`, 'i').exec(xml)
    if (found) {
      tagFound = tagName[i]
      break
    }

    // with attributes
    found = new RegExp(`<${tagName[i]} .*?>(.+?)</${tagName[i]}>`, 'i').exec(xml)
    if (found) {
      tagFound = tagName[i]
      break
    }
  }

  if (found && attributeName) {
    var attribute = new RegExp(`<${tagFound} .*?${attributeName}=\"(.+?)\".*?>`, 'i').exec(found[0])
    if (attribute) {
      return attribute[1]
    }
  }

  return found ? found[1] : null
}
function extract (xml, tagName, attributeName) {
  if (!Array.isArray(tagName)) {
    tagName = [tagName]
  }

  var found = null
  var tagFound = null
  for (var i = 0; i < tagName.length; i++) {
    // without attributes
    found = new RegExp(`<${tagName[i]}\\s*>(.+?)</${tagName[i]}>`, 'i').exec(xml)
    if (found) {
      tagFound = tagName[i]
      break
    }

    // with attributes
    found = new RegExp(`<${tagName[i]} .*?>(.+?)</${tagName[i]}>`, 'i').exec(xml)
    if (found) {
      tagFound = tagName[i]
      break
    }
  }

  if (found && attributeName) {
    var attribute = new RegExp(`<${tagFound} .*?${attributeName}=\"(.+?)\".*?>`, 'i').exec(found[0])
    if (attribute) {
      return attribute[1]
    }
  }

  return found ? found[1] : null
}
function extract ( xml , tagName , attributeName ) { if ( ! Array . isArray ( tagName ) ) { tagName = [ tagName ] } var found = null var tagFound = null for ( var i = 0 ; i < tagName . length ; i ++ ) { // without attributes found = new RegExp ( ` ${ tagName [ i ] } \\ ${ tagName [ i ] } ` , 'i' ) . exec ( xml ) if ( found ) { tagFound = tagName [ i ] break } // with attributes found = new RegExp ( ` ${ tagName [ i ] } ${ tagName [ i ] } ` , 'i' ) . exec ( xml ) if ( found ) { tagFound = tagName [ i ] break } } if ( found && attributeName ) { var attribute = new RegExp ( ` ${ tagFound } ${ attributeName } \" \" ` , 'i' ) . exec ( found [ 0 ] ) if ( attribute ) { return attribute [ 1 ] } } return found ? found [ 1 ] : null }
Extract value between tags.

@param      {<string>}  xml      The xml
@param      {<string|array>}  tagName        The tag name
@param      {<string>}  attributeName  The attribute name
@return     {string | null}
Extract value between tags .