在 R 中打印更长的 XML 个节点

Printing longer XML nodes in R

如何在 R 中 print/display 更长的 XML 节点结果?当我尝试打印它们时,它们只是以“...”结尾

library(rvest)

html <- read_html('https://en.wikipedia.org/wiki/COVID-19_pandemic')

# Works fine as the result is short

html_node(html, xpath = '//*[@id="firstHeading"]')

# Does not print the whole result, ends with'...'

long_path <- html_node(html, xpath = '//*[@id="toc"]/ul')
long_path

你可以这样做:

cat(as.character(long_path))
#> <ul>
#> <li class="toclevel-1 tocsection-1">
#> <a href="#Epidemiology"><span class="tocnumber">1</span> <span class="toctext">Epidemiology</span></a>
#> <ul>
#> <li class="toclevel-2 tocsection-2"><a href="#Background"><span class="tocnumber">1.1</span> <span class="toctext">Background</span></a></li>
#> <li class="toclevel-2 tocsection-3"><a href="#Cases"><span class="tocnumber">1.2</span> <span class="toctext">Cases</span></a></li>
#> <li class="toclevel-2 tocsection-4"><a href="#Deaths"><span class="tocnumber">1.3</span> <span class="toctext">Deaths</span></a></li>
#> </ul>
#> </li>
#> etc...