Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在R中使用库(rvest)和库(xml)为专利数据选择xml_节点_Xml_R_Rvest_Magrittr - Fatal编程技术网

在R中使用库(rvest)和库(xml)为专利数据选择xml_节点

在R中使用库(rvest)和库(xml)为专利数据选择xml_节点,xml,r,rvest,magrittr,Xml,R,Rvest,Magrittr,鉴于EPO专利服务器REPO的以下准XML结构: <ep-patent-document id="EP79301547B1" file="EP79301547NWB1.xml" lang="en" country="EP" doc-number="0007815" kind="B1" date-publ="19871021" status="n" dtd-version="ep-patent-document-v1-1"> <SDOBI lang="en"> <B0

鉴于EPO专利服务器REPO的以下准XML结构:

<ep-patent-document id="EP79301547B1" file="EP79301547NWB1.xml" lang="en" country="EP" doc-number="0007815" kind="B1" date-publ="19871021" status="n" dtd-version="ep-patent-document-v1-1">
<SDOBI lang="en">
<B000>...</B000>
<B100>...</B100>
<B200>
<B210>79301547.0</B210>
<B220>
<date>19790801</date>
</B220>
<B240/>
<B250>en</B250>
<B251EP>en</B251EP>
<B260>en</B260>
</B200>
<B300>...</B300>
<B400>...</B400>
<B500>...</B500>
<B700>...</B700>
<B800>...</B800>
</SDOBI>
<!--  EPO <DP n="1">  -->
<!--  EPO <DP n="2">  -->
<description id="desc" lang="en">...</description>
<claims id="claims01" lang="en">...</claims>
<claims id="claims02" lang="de">...</claims>
<claims id="claims03" lang="fr">...</claims>
</ep-patent-document>
我想选择节点B210中的编号和描述中的文本

使用

library(httr)
library(rvest)
library(XML)
library(magrittr)

files1993 <- list.files("~/Downloads", full.names=TRUE, recursive=TRUE)
y <- files1993[1]
parse1993 <- htmlParse(y) 

parse1993 %>% xml_nodes("description")
parse1993 %>% xml_nodes("SDOBI") %>% xml_nodes("B210")

我确实得到了B210的描述文本,但没有。事实上,对于中提供的任何信息,该命令都不起作用。我必须将SDOBI中给出的信息转换为文本吗?我在这里有点迷路了。非常感谢您的帮助。

很抱歉,此回复有点晚,但我还是想回复,以防其他人在同一主题上需要帮助

首先,使用EPOAPI是一件非常痛苦的事情。xml是一种负担,数据可能非常脏且不一致

似乎是个更好的选择。他们拥有EPO数据集,经过清理,并通过现代RESTful JSON api输出。工作起来容易多了。它们还提供了一些很酷的高级搜索和分析功能,如果你想得到喜欢

他们现在仍处于测试阶段,但我认为他们正在积极吸收新的测试用户。看看吧

为什么不使用xmlParse?parse1993%>%xml\u nodesSDOBI%>%xml\u nodesB210运行良好,然后尝试Hadley的xml2:libraryxml2;xml