% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/html.R
\name{extract_html_text}
\alias{extract_html_text}
\title{Extract readable text from HTML}
\usage{
extract_html_text(
  x,
  selector = NULL,
  xpath = NULL,
  collapse = "\\n",
  trim = TRUE
)
}
\arguments{
\item{x}{Path to an HTML file or a length-one HTML character string.}

\item{selector}{Optional CSS selector.}

\item{xpath}{Optional XPath expression. Supply at most one of \code{selector}
and \code{xpath}.}

\item{collapse}{Character used to join matched nodes.}

\item{trim}{Logical; normalize whitespace and trim the result?}
}
\value{
A length-one character vector containing extracted text.
}
\description{
Extracts text from an HTML file or character string. When the suggested
\code{xml2} package is installed, simple CSS selectors (\code{tag}, \code{.class}, \verb{#id},
or \code{tag.class}) or XPath can target a specific part of the page. A
dependency-free fallback strips markup from the full document.
}
\examples{
html <- "<html><body><h1>Analyst</h1><p>Analyze data.</p></body></html>"
extract_html_text(html)
}
