在xml中获取下一个节点 [英] taking next node in xml

查看:139
本文介绍了在xml中获取下一个节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在mfc中获得了一个使用msxml在listcontrol中显示xml节点的应用程序.
如果我有如下的xml

<医院>
<患者>
< name> a
< place> zzz

<患者>
< name> vv
< place> bbb



我的问题是我必须在一个列表控件中显示名字和位置,并在另一个列表控件中显示名字和位置.如何使用msxml节点访问名字和位置...

I got an application in mfc for displaying xml node in listcontrol using msxml.
if i have the xml as follows

<hospital>
<patient>
<name>a
<place>zzz

<patient>
<name>vv
<place>bbb



My que is that i have to display first name and place in one list control and second name and place in another list control.How can i access next name and place using msxml node...

推荐答案

我假设您使用的是IXMLDOMNode,然后只需使用nextSibling方法.
I am assuming you are having a IXMLDOMNode then simply use nextSibling method.


如果我在for循环中使用下一个同级方法,我将获得全部单列表控件中的文本节点.我必须在一个列表控件中显示一个位置和名称,在第二个列表控件中显示另一位置.我的代码如下....


if i use next sibling method in a for loop i wiil get all text nodes in single list control.i have to display one place and name in one list control and another in 2nd list control.my code as follows....


  MSXML2::IXMLDOMElementPtr m_pDocRoot;
  MSXML2::IXMLDOMNodePtr pChild = m_pDocRoot->firstChild;
  DisplayChildren(pChild);

 void CPatientInformationDlg::DisplayChildren(MSXML2::IXMLDOMNodePtr pParent)
 {
      DisplayChild1(pParent);
 }
 void CPatientInformationDlg::DisplayChild1(MSXML2::IXMLDOMNodePtr  pChild)
 {
  MSXML2::IXMLDOMNodePtr pChild1;
  for ( pChild1= pChild->firstChild;
      NULL != pChild1;
      pChild1 = pChild1->nextSibling)
  {
      VARIANT v;
      v=pChild1->nodeTypedValue;
      m_Llist2.InsertItem(0,v.bstrVal);
  }

}

plzzz(如果有人知道),请使用示例代码告诉ans ....

plzzz if anyone know this ans plzzzzzzzz tell ans with example code....


这篇关于在xml中获取下一个节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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