Dear list
I tried to read an xml file using the xml package. Unfortunately, some encoding
problems occure. E.g. german Umlaut will be red correctly. I assume that the
occurs due to (internal?) conversion to utf-8. To illustrate the problem, I
have wrote to xml files.
File Test 1
-----------
<?xml version="1.0" encoding="ISO-8859-1"?>
<Daten>
<ITEM>
<Messdaten>
<MESSUNG>
<BEZEICHNUNG>Länge</BEZEICHNUNG>
</MESSUNG>
</Messdaten>
</ITEM>
</Daten>
File Test 2
-----------
<?xml version="1.0" encoding="utf-8"?>
<Daten>
<ITEM>
<Messdaten>
<MESSUNG>
<BEZEICHNUNG>Länge</BEZEICHNUNG>
</MESSUNG>
</Messdaten>
</ITEM>
</Daten>
The following code shows that i cannot extract the Value of "Länge" correctly.
Any help is very welcom.
---------------------------------------- Code Start ------------
> fname1 <- "test1.xml"
> fname2 <- "test2.xml"
> doc <- xmlTreeParse(fname1,useInternalNodes=T)
> show(doc)
<?xml version="1.0" encoding="ISO-8859-1"?>
<Daten>
<ITEM>
<Messdaten>
<MESSUNG>
<BEZEICHNUNG>Länge</BEZEICHNUNG>
</MESSUNG>
</Messdaten>
</ITEM>
</Daten>
> xpathApply(doc,"//MESSUNG/BEZEICHNUNG", xmlValue)
[[1]]
[1] "Länge"
> doc <- xmlTreeParse(fname2,useInternalNodes=T)
> show(doc)
<?xml version="1.0" encoding="utf-8"?>
<Daten>
<ITEM>
<Messdaten>
<MESSUNG>
<BEZEICHNUNG>Länge</BEZEICHNUNG>
</MESSUNG>
</Messdaten>
</ITEM>
</Daten>
> xpathApply(doc,"//MESSUNG/BEZEICHNUNG", xmlValue)
[[1]]
[1] "Länge"
---------------------------------------- Code Stop ------------
I am using the following system.
R version 2.9.1 (2008-06-26)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Microsoft Windows XP
XML_2.6-0.zip downloaded from
http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.9/
[[alternative(swapped) HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.