我正在使用R解析XML文件,但我總是收到錯誤消息,說XML內容似乎不是XML,但是XML文件確實包含XML數據,即使我只是把一個簡單的標籤。請參閱下面的示例R:XML內容似乎不是XML
有關如何解決此問題的任何建議?
R代碼裏面:
xmlinfile = "sample.xml"
xml = xmlInternalTreeParse(xmlinfile)
sample.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"
提前致謝。
相關,但可能不是重複:http://stackoverflow.com/questions/17954817/xml -content-does-not-seem-to-be-xml?rq = 1 – 2014-03-07 02:09:21
你可以在解析它之前打印文件嗎?你確定它的開放* *特定的'sample.xml'嗎? – 2014-03-07 02:09:51
@LegoStormtroopr,我解析後打印文件,並得到:> print(xml) [1]「錯誤:XML內容似乎不是XML:'sample.xml'\ n」 attr(,「class」 ) [1]「try-error」 attr(,「condition」) –
Ianthe