Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/78.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.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解析自定义XML文件_R_Xml_Xpath - Fatal编程技术网

R解析自定义XML文件

R解析自定义XML文件,r,xml,xpath,R,Xml,Xpath,我有一个自定义XML文件,可以通过XMLLint进行验证。jQuery也能很好地解析这个文件。然而,我正试图在R中创建一个XML解析器,而对于一个xpath请求,我们一直在使用{XML_nodeset(0)} 下面是一个简短的XML版本 <?xml version="1.0" encoding="UTF-8"?> <Sequences> <Sequence ID="sp|O95256|I18RA_HUMAN" Status="Solenoid" MeanLen

我有一个自定义XML文件,可以通过XMLLint进行验证。jQuery也能很好地解析这个文件。然而,我正试图在R中创建一个XML解析器,而对于一个
xpath
请求,我们一直在使用
{XML_nodeset(0)}

下面是一个简短的XML版本

<?xml version="1.0" encoding="UTF-8"?>
<Sequences>
   <Sequence ID="sp|O95256|I18RA_HUMAN" Status="Solenoid" MeanLength="26.0">
      <Description>sp|O95256|I18RA_HUMAN Interleukin-18 receptor accessory protein OS=Homo sapiens GN=IL18RAP PE=1 SV=1 [HUMAN]</Description>
      <Unit Boundaries="[53, 70]" Regularity="-9.0" Sequence="SHFCHRNRLSPKQVPEH" />
      <Unit Boundaries="[141, 163]" Regularity="-4.0" Sequence="KMILEVKPQTNASCEYSASHKQ" />
      <Unit Boundaries="[228, 261]" Regularity="7.0" Sequence="VSSWTVRAVVQVRTIVGDTKLKPDILDPVEDTL" />
      <Unit Boundaries="[308, 334]" Regularity="0.0" Sequence="KSTLKDEIIERNIILEKVTQRDLRRK" />
      <Unit Boundaries="[334, 359]" Regularity="-1.0" Sequence="FVCFVQNSIGNTTQSVQLKEKRGVV" />
      <Unit Boundaries="[359, 393]" Regularity="8.0" Sequence="LLYILLGTIGTLVAVLAASALLYRHWIEIVLLYR" />
      <Unit Boundaries="[393, 416]" Regularity="-3.0" Sequence="TYQSKDQTLGDKKDFDAFVSYAK" />
   </Sequence>
</Sequences>
我不知道如何访问
序列的属性
及其子项的属性

> xml_children(Sequence[0])
{xml_nodeset (0)}

我的XML有问题吗?不过jQuery解析得很好

R向量开始索引可能在1而不是0处重复,
Sequence[1]
返回您期望的值R向量开始索引可能在1而不是0处重复,
Sequence[1]
返回您期望的值
> Sequence
{xml_nodeset (1)}

> Sequence[0]
{xml_nodeset (0)}
> xml_children(Sequence[0])
{xml_nodeset (0)}