R/has_xml_opening_tag.R

Defines functions has_xml_opening_tag

Documented in has_xml_opening_tag

#' Is an XML opening tag with value 'section' present among the lines of
#'   the text?
#' @param lines lines of an XML text
#' @param section if NA, this function returns TRUE if there is any
#'   XML opening tag. If \code{section} is set to a certain word,
#'   this function returns TRUE if that tag matches \code{section}
#' @return lines of XML text
#' @author Richèl J.C. Bilderbeek
#' @export
has_xml_opening_tag <- function(
  lines,
  section = NA
) {
  if (is.null(section) ||
      (!is.character(section) && !is_one_na(section))
  ) {
    stop("'section' must be NA or a word")
  }
  if (is_one_na(section)) {
    tag <- get_xml_opening_tag(lines)
    return(!is_one_na(tag))
  }
  !is_one_na(
    find_first_xml_opening_tag_line(lines, section)
  )
}

Try the beautier package in your browser

Any scripts or data that you put into this service are public.

beautier documentation built on Nov. 2, 2023, 5:08 p.m.