title: PCDATA invalid Char in R
body: <p>First of all, I am sorry if this is a repeated question. I tried for several hours already and I see different solutions for PHP or other languages but not for R.</p>
  
  <p>I am retrieving data from the last.fm website using their API.
  You do need an API key to retrieve the data I am trying to get but I will make it simpler here and hopefully you can answer my question.</p>
  
  <p>Here is my problem:
  At certain point, when retrieving the data, I encounter an error which stops my request. I skipped it once but it comes back again and again. I always get the same: PCDATA invalid Char value #</p>
  
  <p>Here is an example:</p>
  
  <pre><code>string = "&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\n&lt;lfm status=\"ok\"&gt;\n&lt;results for=\"a\" xmlns:opensearch=\"http://a9.com/-/spec/opensearch/1.1/\"&gt;\n&lt;opensearch:Query role=\"request\" searchTerms=\"a\" startPage=\"1382\" /&gt;\n&lt;opensearch:totalResults&gt;212588&lt;/opensearch:totalResults&gt;\n&lt;opensearch:startIndex&gt;1381&lt;/opensearch:startIndex&gt;\n&lt;opensearch:itemsPerPage&gt;1&lt;/opensearch:itemsPerPage&gt;&lt;artistmatches&gt;\n&lt;artist&gt;\n    &lt;name&gt;!B0A \0348E09;&amp;gt;2&lt;/name&gt;\n                &lt;listeners&gt;1672&lt;/listeners&gt;\n                &lt;mbid&gt;&lt;/mbid&gt;\n                        &lt;url&gt;http://www.last.fm/music/!B0A+%1C8E09;%3E2&lt;/url&gt;\n    &lt;streamable&gt;0&lt;/streamable&gt;\n            &lt;image size=\"small\"&gt;http://userserve-ak.last.fm/serve/34/88015017.png&lt;/image&gt;\n        &lt;image size=\"medium\"&gt;http://userserve-ak.last.fm/serve/64/88015017.png&lt;/image&gt;\n        &lt;image size=\"large\"&gt;http://userserve-ak.last.fm/serve/126/88015017.png&lt;/image&gt;\n        &lt;image size=\"extralarge\"&gt;http://userserve-ak.last.fm/serve/252/88015017.png&lt;/image&gt;\n        &lt;image size=\"mega\"&gt;http://userserve-ak.last.fm/serve/_/88015017/B0A+8E092+15286997.png&lt;/image&gt;\n    &lt;/artist&gt;&lt;/artistmatches&gt;\n&lt;/results&gt;&lt;/lfm&gt;\n"
  </code></pre>
  
  <p>When I try to parse this text I get the error:</p>
  
  <pre><code>doc = xmlParse(string, asText = TRUE)
  PCDATA invalid Char value 28
  Error: 1: PCDATA invalid Char value 28
  </code></pre>
  
  <p>I believe the part that is making this happen comes from this part of the string:</p>
  
  <pre><code>&lt;name&gt;!B0A \0348E09;&amp;gt;2&lt;/name&gt;\n 
  </code></pre>
  
  <p>But I can't be sure now.</p>
  
  <p>What I am looking for is one of these solutions, being the first one the ideally situation but any of the others will make me happy:</p>
  
  <p>1 - Allow R to receive these invalid characters</p>
  
  <p>2 - Eliminate the invalid characters and continue with the parse without stopping.</p>
  
  <p>3 - Skip the string with the invalid characters and continue with the parse</p>
  
  <p>4 - Create a function to find the invalid characters so I can include that when retrieving the data from last.fm</p>
  
  <p>I hope you can understand the question and help me with it.
  Thanks in advance</p>