<data> <FcCom id="75" company="啊啊" scompany="上社產" /> <FcCom id="4" company="發有限公司" scompany="聯泰房產" /> <FcCom id="3" company="公司汕頭公司" scompany="中信房產" /> …………………… 假如有這樣一段XML文件,我想顯示前12條數據,請問該怎么寫呢?
2 回答

慕娘9325324
TA貢獻1783條經驗 獲得超4個贊
對上面的朋友答復做一點補充:
XDocument doc = XDocument.Parse(xml);
var list = (from node in doc.Root.Descendants("FcCom")
where node.Attribute("scompany")!=null
select node.Attribute("scompany").Value).Take(12);
如果要加上排序,分頁等,你可以再自己看看OrderBy()和Skip()方法。
- 2 回答
- 0 關注
- 387 瀏覽
添加回答
舉報
0/150
提交
取消