尝试从XML提取用户输入

时间:2019-04-17 15:59:44

标签: r xml

尝试从XML代码中提取两个用户输入。

我将数据读入数据框,其中一列包含XML。

它抱怨说它不是XML

这是第一个

shpt$t <- '<form><text id="UserText1" label="Please provide your current URL or a proposed title for your docshare site:" mandatory="true" multiline="false" readonly="false" visible="true"> http://docshare.net/org/bo/BOP/RTSupDocLibrary/eample.xlsx</text><text id="UserTextArea1" label="Provide details of the assistance you need:" mandatory="false" multiline="true" readonly="false" visible="true">Hello, Would like assistance in creating a DocShare site for our group. Thank you. </text></form>' 
doc = xmlInternalTreeParse("shpt$t")

Error: XML content does not seem to be XML: 'shpt$t'

因此,我试图对匹配进行模式匹配以使其正确,但是我认为这不是正确的方法。

test <- sub(".*true *(.*?) *text.*", "\\1", shpt$t)
shpt$v1 <- gsub("\">|</", "", test)

我预期的结果是另外两个变量

shpt$v1 <- "http://docshare.net/org/bo/BOP/RTSupDocLibrary/eample.xlsx"
shpt$v2 <- "Hello, Would like assistance in creating a DocShare site for our group. Thank you."

0 个答案:

没有答案