xml - R : XML content does not seem to be XML

标签 xml r

我正在使用 R 解析 XML 文件,但我总是收到错误消息,说 XML 内容似乎不是 XML,但 XML 文件确实包含 XML 数据,即使我只是放入一个简单的标记也是如此。请看下面的示例

关于如何解决这个问题有什么建议吗?

R 代码:

xmlinfile = "sample.xml"
xml = xmlInternalTreeParse(xmlinfile)

示例.xml

<?xml version="1.0" encoding="UTF-8"?>
<root>
   <name>Sample</name>
</root>

错误:

Error: XML content does not seem to be XML: 'sample.xml'

根据要求,下面是我在解析前打印文件时得到的结果:

 xmlinfile = "sample.xml"
 sampleFile<-file(xmlinfile,"w")
 print(sampleFile)

description     class      mode     text       opened     can read    can write 
"sample.xml"    "file"      "w"    "text"     "opened"      "no"        "yes"

提前致谢。

最佳答案

感谢大家的评论和回答,我想我找到了答案。我的 XML 文件与导致问题的 R 脚本不在同一位置。

但错误信息似乎不正确或不直观。但无论如何,它现在有效。 再次感谢大家。 ;)

关于xml - R : XML content does not seem to be XML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22240033/

相关文章:

r - 有没有办法为pdf制作没有线条/边框的kable?

r - 清除 R 中的最后一个错误

xml - 如何对XML文件进行以下编辑?

xml - XSLTProcessor.transformToFragment( ) 在 Microsoft edge 上返回 null

iphone - 向 NSDictionary 添加条目不起作用

r - 如何更改 R googleVis sankey 图表中的节点和链接颜色

r - 如何在使用 ggplot2 绘制的直方图上绘制箭头?

xml - XSD all 和 XSD sequence 之间的中间方式

.net - 解析 XML 的不同方法

r - for 循环 - 替换的长度为零