title: Rvest - Error in UseMethod("read_xml") : no applicable method for 'read_xml' applied to an object of class "factor"
body: <p>I am using the below rvest code:</p>
  
  <pre><code>library(rvest)
  
  URL &lt;- "http://www.soccerstats.com/matches.asp" #Feed page
  
  WS &lt;- read_html (URL) #reads webpage into WS variable
  
  URLs &lt;- WS %&gt;% html_nodes ("a:nth-child(1)") %&gt;% html_attr("href")         %&gt;% as.character() # Get the CSS nodes &amp; extract the URLs 
  
  URLs &lt;- paste0("http://www.soccerstats.com/",URLs) 
  
  grepl("pmatch", oversdf$URLs)
  
  URLs &lt;-subset(oversdf, grepl("pmatch", oversdf$URLs),stringsAsFactors       =       FALSE)
  
  Catcher1 &lt;- data.frame(FMatch=character(),TotalGoals=character    (),stringsAsFactors = FALSE)
  
  #Start of for loop
  
  for (i in URLs) {
  
  WS1 &lt;- read_html(i)
  FMatch &lt;- WS1 %&gt;% html_nodes("H1") %&gt;% html_text() %&gt;% as.character()
  TotalGoals &lt;- WS1 %&gt;% html_nodes(".trow3+ .trow2 td~ td+ td font b") %&gt;%     html_text() %&gt;% as.character()
  temp &lt;- data.frame(FMatch,TotalGoals)
  Catcher1 &lt;- rbind(Catcher1,temp)
  cat("*")
  
  }
  </code></pre>
  
  <p>When it tries to run the loop I get the error: </p>
  
  <p>Error in UseMethod("read_xml") : no applicable method for 'read_xml' applied to an object of class "factor"</p>
  
  <p>Looking at forum posts I need to use stringsAsFactors = FALSE, as my dataframe will be storing the field data as factors instead of strings.</p>
  
  <p>The only place I can think that its left to go is on the temp df:</p>
  
  <p>temp &lt;- data.frame(FMatch,TotalGoals)</p>
  
  <p>But however I try apply it to the above df it syntax errors, any ideas ?</p>
  
  <p>(Obviously I'm a newbie to this so I might be wrong about the above is whats causing the error, just looks like it is from the various forums posts I have read)</p>
  
  <p>Cheers</p>