快精灵印艺坊 您身边的文印专家
广州名片 深圳名片 会员卡 贵宾卡 印刷 设计教程
产品展示 在线订购 会员中心 产品模板 设计指南 在线编辑
 首页 名片设计   CorelDRAW   Illustrator   AuotoCAD   Painter   其他软件   Photoshop   Fireworks   Flash  

 » 彩色名片
 » PVC卡
 » 彩色磁性卡
 » 彩页/画册
 » 个性印务
 » 彩色不干胶
 » 明信片
   » 明信片
   » 彩色书签
   » 门挂
 » 其他产品与服务
   » 创业锦囊
   » 办公用品
     » 信封、信纸
     » 便签纸、斜面纸砖
     » 无碳复印纸
   » 海报
   » 大篇幅印刷
     » KT板
     » 海报
     » 横幅

循环读取重名节点的方式

怎?N?影盐蚁旅娴镍ml格式的文件里面的结点中值循环读出来  
<?xml  version="1.0"  standalone="yes"?>  
<InOutStore  xmlns="http://tempuri.org/InOutStore.xsd">  
   <OutStore>  
       <code>6900916200010</code>  
       <time>2005-7-11  20:47:54</time>  
   </OutStore>  
   <OutStore>  
       <code>1P25-68596-01</code>  
       <time>2005-7-11  20:48:10</time>  
   </OutStore>  
   <OutStore>  
       <code>6901028337168</code>  
       <time>2005-7-11  20:48:20</time>  
   </OutStore>  
   <OutStore>  
       <code>6901028337168</code>  
       <time>2005-7-11  20:48:32</time>  
   </OutStore>  
   <OutStore>  
       <code>6901028337168</code>  
       <time>2005-7-11  20:48:41</time>  
   </OutStore>  
   <PocketId>  
       <pid>001</pid>  
   </PocketId>  
</InOutStore>  
 
用 节点[索引]的模式可以读取重名节点, 下面是代码
#if  !defined(__MSXML3__)  
 
#define  __MSXML3__  
 
#import  "msxml3.dll"    
using  namespace  MSXML2;  
#endif  
 
           IXMLDOMDocument2Ptr  xml;  
xml.CreateInstance(__uuidof(MSXML2::DOMDocument));  
xml->load("xxxx.xml");  
 
CStringArray  timeA,  codeA;  
 
int  i=  1;  
BOOL  bNode  =  TRUE;  
while  (bNode)  
{  
 
IXMLDOMNodePtr  node;  
CString  strRoot;  
 
strRoot.Format("/InOutStore/OutStore[%d]",  i++);  
node=xml->selectSingleNode(_bstr_t(strRoot));  
if  (node)  
{  
     IXMLDOMNodePtr  nodeCode,  nodeTime;  
     VARIANT  value;  
     CString  strCode  =  strRoot  +  "/code";  
   nodeCode=xml->selectSingleNode(_bstr_t(strCode));  
     nodeCode->get_nodeTypedValue(&value);  
 
   CString  str1(value.bstrVal);  
   SysFreeString(value.bstrVal);  
   codeA.Add(str1);  
 CString  strTime  =  strRoot  +  "/time";  
   nodeTime=xml->selectSingleNode(_bstr_t(strTime  ));  
     nodeTime->get_nodeTypedValue(&value);  
 
   CString  str2(value.bstrVal);  
   SysFreeString(value.bstrVal);  
   timeA.Add(str2);  
}  
else  
       bNode  =  FALSE;  
}
返回类别: 教程
上一教程: XSL简明教程(4)在服务器端的实现
下一教程: 使用XML分解器

您可以阅读与"循环读取重名节点的方式"相关的教程:
· XML枚举一个节点的所有属性的方式
· XML的简朴读取与写入
· 使用.NET读取XML文件
· 获取mssql的xml返回结构的方式
· 用XMLHTTP读取网页源代码
    微笑服务 优质保证 索取样品