【发布时间】:2020-03-31 08:33:43
【问题描述】:
我有几个包含以下节点的 KML:
<description><![CDATA[<img src="image_23037733.png" height="400" width="1200" align ="middle" />]]></description>
我想将所有出现的文本“image_” 更改为“path/on/another/hdd/image_”。如何编辑以下代码来完成任务?
library(XML)
doc <- xmlTreeParse("File.kml", useInternal = TRUE)
nodes <- getNodeSet(doc, "description")
lapply(nodes, function(n) {
xmlValue(n) <- gsub("image_","path/on/another/hdd/image_",xmlValue(n))
})
Error in `xmlValue<-`(`*tmp*`, value = "<img src=\"path/on/another/hdd/image_1.png\" height=\"400\" width=\"1200\" align =\"middle\" />") :
Cannot set the content of a node that is not an XMLInternalTextNode or a node containing a text node
【问题讨论】: