zoukankan      html  css  js  c++  java
  • 获取xml字符串中的属性值

    pagexml = @"<?xml version='1.0' encoding='utf-8'?>

    <DATAPACKET Version='2.0'>
    <METADATA>
    <FIELDS>
    <FIELD attrname='vMbillID' fieldtype='string' required='true' WIDTH='20'>
    <PARAM Name='ORIGIN' Value='vMbillID' Roundtrip='True'/>
    </FIELD>
    <FIELD attrname='rq' fieldtype='SQLdateTime'>
    <PARAM Name='ORIGIN' Value='rq' Roundtrip='True'/>
    </FIELD>
    </FIELDS>
    <PARAMS/>
    </METADATA>
    <ROWDATA>
    <ROW vMbillID='02_xpd000005' rq='20161125T09:40:10000' vShop='02' vEmpCode='02_000' vStyle='32460006' vColor='0' vSize='0' fPrice='49' zk='1' fRealPrice='49' fRealMoney='49' fQuantity='1'/>
    <ROW vMbillID='02_xpd000005' rq='20161125T09:40:10000' vShop='02' vEmpCode='02_000' vStyle='16111613' vColor='07' vSize='0' fPrice='209' zk='0.88' fRealPrice='184' fRealMoney='184' fQuantity='1'/>
    </ROWDATA>
    </DATAPACKET>";


    XmlDocument doc = new XmlDocument();
    doc.LoadXml(pagexml);
    XmlNodeList DATAPACKET = doc.SelectNodes("/DATAPACKET");
    if(DATAPACKET != null)
    {
    foreach (XmlNode schoolNode in DATAPACKET)
    {
    XmlNode gradesNode = schoolNode.SelectSingleNode("ROWDATA");
    if(gradesNode != null)
    {
    foreach (XmlNode rows in gradesNode)
    {
    DataRow R = dt.NewRow();
    R["DocNo"] = rows.Attributes["vMbillID"].Value;
    R["SalesDate"] = rows.Attributes["vMbillID"].Value;
    R["SalesTime"] = rows.Attributes["vMbillID"].Value;
    R["AdjustMoney"] = rows.Attributes["vMbillID"].Value;
    dt.Rows.Add(R);
    }
    dv = new DataView(dt);
    }

    }
    }

  • 相关阅读:
    NSString、NSMutableString基本用法
    iOS开发之UITextField的使用详解
    iOS学习—JSON数据解析
    iOS下json的解析 NSJSONSerialization
    NSJSONSerialization介绍
    [iOS经典面试题]用变量a给出下面的定义
    sizeToFit()使用心得
    李洪强-C语言5-函数
    【C语言】10-字符和字符串常用处理函数
    cocos2d-x 2.x 支持多个方向屏幕翻转
  • 原文地址:https://www.cnblogs.com/liwp/p/7196818.html
Copyright © 2011-2022 走看看