Perl LibXML解析和选择元素快速
当涉及到编程时,我总是被一些逻辑问题所困扰。我认为这是合乎逻辑的,很容易,但对我来说很难,因为我无法到达那里。我正在使用XML::LibXML解析XML文件。现在在下面的代码中Perl LibXML解析和选择元素快速,perl,xpath,xml-parsing,xml-libxml,Perl,Xpath,Xml Parsing,Xml Libxml,当涉及到编程时,我总是被一些逻辑问题所困扰。我认为这是合乎逻辑的,很容易,但对我来说很难,因为我无法到达那里。我正在使用XML::LibXML解析XML文件。现在在下面的代码中 <CommentsCorrectionsList> <CommentsCorrections RefType="Cites"> <RefSource>Brain Cogn. 2005 Jul;58(2):245</RefSource> </CommentsCorrec
<CommentsCorrectionsList>
<CommentsCorrections RefType="Cites">
<RefSource>Brain Cogn. 2005 Jul;58(2):245</RefSource>
</CommentsCorrections>
<CommentsCorrections RefType="RepublishedIn">
<RefSource>Brain Cogn. 2005 Jul;58(2):246-8</RefSource>
<PMID Version="1">16044513</PMID>
</CommentsCorrections>
<CommentsCorrections RefType="PartialRetractionOf">
<RefSource>Curr Opin Organ Transplant. 2001 Mar;6(1):95-101</RefSource>
</CommentsCorrections>
</CommentsCorrectionsList>
但是在这种情况下,如何避免foreach中的RefType=“Cites”,并使其与我想要的其他RefType相等。我的意思是我不知道这样的布尔值是否可以用在foreach语句中。我试着寻找,也试了试,但什么都没有。非常感谢您的帮助
多谢各位
CommentsCorrectionList/CommentsCorrections[@RefType != "Cites"]
我个人用这个作为我的参考,但可能有更友好的参考。是的。这是我脑海中跳过的。谢谢你的推荐,真的很有帮助。谢谢你的池上。
if(!($foo->findnodes('CommentsCorrectionList/CommentsCorrections[@RefType="Cites"]'))){
do foreach and get the data
}
CommentsCorrectionList/CommentsCorrections[@RefType != "Cites"]