使用VB解析PubMed XML [英] Parsing PubMed XML using VB

查看:245
本文介绍了使用VB解析PubMed XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Dim oNode As IXMLDOMNode

    For Each oNode In oItemNodes
        Set sPMIDNode = oNode.selectSingleNode("//PMID")
        If Not sPMIDNode Is Nothing Then sPMID = sPMIDNode.Text
        Set sTitleNode = oNode.selectSingleNode("//ArticleTitle")
        If Not STitleNode Is Nothing Then sTitle = STitleNode.Text
        Set SAbstractNode = oNode.selectSingleNode("//AbstractText")
        If Not SAbstractNode Is Nothing Then sAbstract = SAbstractNode.Text
    Next




当缺少数据时,我无法使PMID,文章标题和摘要文本正确地排列在表中.我采用了以下代码,但只重复了节点列表中的第一项.如何遍历节点列表并获取文本值(当文本值存在并且所有内容都排列在结果表中)?

来自PubMed的XML有时具有摘要,有时则没有. oItemNodes是PubMed Articles的节点列表. oNode正确增加. SelectSingleNode不起作用.它只是找到第一条.




I am having trouble getting the PMID, Article Title, and Abstract Text to line up correctly in a table when there is missing data. I have resorted to the following code, but I just get the first item in the node list repeated. How can I loop through the node list and get text values when they exist and have everything line up in the resulting table?

The XML from PubMed sometimes has an abstract and sometimes it does not. The oItemNodes is a node list of PubMed Articles. oNode increments correctly. SelectSingleNode does not work. It just finds the first Article.

推荐答案

try:
try:
Dim oNode As IXMLDOMNode

    For Each oNode In oItemNodes
        Set sPMIDNode = oNode.selectSingleNode("/PMID")
        If Not sPMIDNode Is Nothing Then sPMID = sPMIDNode.Text
        Set sTitleNode = oNode.selectSingleNode("/ArticleTitle")
        If Not STitleNode Is Nothing Then sTitle = STitleNode.Text
        Set SAbstractNode = oNode.selectSingleNode("/AbstractText")
        If Not SAbstractNode Is Nothing Then sAbstract = SAbstractNode.Text
    Next



参考: http://msdn.microsoft.com/zh-CN -us/library/windows/desktop/ms757846(v = vs.85).aspx [



ref: http://msdn.microsoft.com/en-us/library/windows/desktop/ms757846(v=vs.85).aspx[^]


这篇关于使用VB解析PubMed XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆