[R] How to read XML in UTF-8 format?

Rainer Hurling rhurlin at gwdg.de
Mon Oct 15 17:27:22 CEST 2012


On 15.10.2012 14:49 (UTC+2), Manish Gupta wrote:
> How to read xml in UTF-8 format.  I have one XML file but i want to read it
> in UTF-8 format. How this is possible? 
> 
> <barplot> 
>             <cd> 
>                 <name>表</name> 
>                 <value1>3</value1> 
>                 <value2>2.9</value2> 
>             </cd>   
>             <cd> 
>                 <name>笔</name> 
>                 <value1>3.3</value1> 
>                 <value2>3</value2> 
>             </cd> 
>             <cd> 
>                 <name>铅笔</name> 
>                 <value1>2.3</value1> 
>                 <value2>2.9</value2> 
>             </cd> 
>             <cd> 
>                 <name>书</name> 
>                 <value1>3.4</value1> 
>                 <value2>2.6</value2> 
>             </cd> 
>             <cd> 
>                 <name>玻璃</name> 
>                 <value1>3.1</value1> 
>                 <value2>2.4</value2> 
>             </cd> 
> </barplot> 
> 
> Regards

Given, that the above lines are stored in an UTF-8 encoded file named
'xml-unicode', the following works for me:

library(XML)
xmlParseDoc("xml-unicode", encoding="UTF-8")

I think, there a smarter solutions.

Hope this helps,
Rainer


> View this message in context: http://r.789695.n4.nabble.com/How-to-read-XML-in-UTF-8-format-tp4646232.html
> Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list