` are headers if
there is one, otherwise the leading rows made only of `| ` cells. A
` | ` among ` | `s is a row label, not a header. Use `TRUE`, `FALSE` or
row numbers to choose explicitly:
```{r}
doc <- html_parse("")
tab <- html_element(doc, "table")
html_table(tab)
html_table(tab, header = TRUE)
```
Blank names become `V1`, `V2`, ...; duplicate names get `make.unique()`
suffixes. Rows are read head first, then bodies, then footers, and
footers are data. Rows of a table nested inside a cell stay out of the
outer table, and the nested table's text stays out of the cell.
Missing slots (in ragged rows) are `NA`; an empty cell is `""`. Mark
placeholders as missing with `na`:
```{r}
doc <- html_parse("")
html_table(html_element(doc, "table"), na = "-")
```
## Lists
`html_list()` reads one `` or ``. Each item's text leaves out the
lists nested inside it:
```{r}
doc <- html_parse("
")
menu <- html_element(doc, "ul")
html_list(menu)
```
`mode = "tree"` keeps the nesting, including lists inside wrapper
elements such as the `` above:
```{r}
tree <- html_list(menu, mode = "tree")
tree
tree$items[[2]]$children[[1]]$type
```
To read many lists, `lapply()` over a nodeset passes one node at a time:
```{r}
lapply(html_elements(doc, "ul ul, ol"), html_list)
```
|