【发布时间】:2014-05-24 07:49:05
【问题描述】:
我正在尝试查看 XML 中的 a 标记。我的脚本一直运行到 dbReferences(一个条目有几个),但如果 'type' = "EC",我只想使用 'id'。
我正在考虑执行某种类型的 if 语句,它会在获取 id 之前查看 dbReference 的“类型”:
foreach $entry (@{$data->{entry}}) {
foreach $ref (@{$entry->{dbReference}}) {
if($ref type ="EC"){
#then print the id
}
}
}
编辑: 条目 XML 将像这样格式化,连续有很多 dbReferences,需要检查:
<dbReference type="NCBI Taxonomy" id="9606"/>
<dbReference type="PubMed" id="8274401"/>
<dbReference type="EC" id="1.1.5.54"/>
有什么想法吗?
【问题讨论】:
-
yu应该写
if ($ref eq "EC") -
dbReference 有一堆参数,id、长度、类型、属性等。如何在if语句中指定我是测试类型?
-
您能否发布一个示例输入以及您所解释的内容?
-
我更新了主帖,对 xml 的外观进行了编辑。代码已经用 XML::Simple 进行了解析。我不确定如何访问 dbReference 的类型和 id 参数,因为它们不在标记的主体中。