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); }}
}