简体   繁体   English

XML内容似乎不是XML

[英]XML content does not seem to be XML

Above is the error I have when I was trying to read 80 xml files in a for loop. 以上是我尝试在for循环中读取80个xml文件时遇到的错误。 The problem is with xmlParse . 问题出在xmlParse It worked well with others, but only 1 file. 它与其他人一起运行良好,但只有1个文件。 I am not really understand about built function. 我不太了解内置功能。 I just want to ask how to skip xmlParse error. 我只想问一下如何跳过xmlParse错误。

xmlParse(file) XMLPARSE(文件)

Error: XML content does not seem to be XML: 'sample.part40.xml' 错误:XML内容似乎不是XML:“ sample.part40.xml”

When iterating over a list of files, if you see this error, it normally means the content of that specific file is not xml . 遍历文件列表时,如果看到此错误,则通常表示该特定文件的内容不是xml This happens often when the files have been scraped off the web (for example, one might be a generic 404 file instead with no xml content). 当文件从网络上被抓取时,通常会发生这种情况(例如,一个文件可能是通用的404文件而不是没有xml内容)。

I normally use something like this: 我通常使用这样的东西:

 results <- lapply(listOfFiles, function(f)  
                {X <- try(xmlParse(f))
                 if (inherits(X, "try-error")) NA else X} )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM