I'm having a problem writing my parsed html to a file. I have this data from a table specified from xpath but when I try to write it to a file, I get "Error in cat(list(...)).
> fileUrl <- "http://www.w3schools.com/html/html_tables.asp"
> library(XML)
> htmlFile <- htmlTreeParse(fileUrl, useInternal = TRUE)
> # and then I grab the table
> urlParse <- xpathSApply(htmlFile, "//table[@class='reference']")
> urlParse[[1]]
[[1]]
<table class="reference" style="width:100%">
<tr><th>Number</th>
<th>First Name</th>
<th>Last Name</th>
<th>Points</th>
</tr>
<tr><td>1</td>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
<tr><td>2</td>
<td>John</td>
<td>Doe</td>
<td>80</td>
</tr>
<tr><td>3</td>
<td>Adam</td>
<td>Johnson</td>
<td>67</td>
</tr>
<tr><td>4</td>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
</table>
this is fine, but when I write this to a file, I get:
> write(urlParse[[1]], file = "file.txt")
Error in cat(list(...), file, sep, fill, labels, append) :
argument 1 (type 'externalptr') cannot be handled by 'cat'
but when I do something like:
> write(c(3234,234,23,4,234), file = "file.txt")
everything is fine. Is it because it's a list? I tried urlParse[1], toString(urlParse[1]), urlParse[[1]][1]. Not sure why.