第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何在ASP.Net中通過(guò)id從xml中讀取特定數(shù)據(jù)

如何在ASP.Net中通過(guò)id從xml中讀取特定數(shù)據(jù)

C#
藍(lán)山帝景 2023-12-17 16:57:33
我想根據(jù)其 id 選擇特定數(shù)據(jù),這里是 xml 的示例<?xml version="1.0" encoding="ISO-8859-1"?><productdetails>    <product>        <Id>1</Id>        <product_name>banana</product_name>        <product_price>5.00</product_price>        <product_description>its banana</product_description>        <product_quantity>12</product_quantity>    </product>    <product>        <Id>2</Id>        <product_name>mango</product_name>        <product_price>10.00</product_price>        <product_description>its mango</product_description>        <product_quantity>12</product_quantity>    </product>    <product>        <Id>3</Id>        <product_name>orange</product_name>        <product_price>3.00</product_price>        <product_description>its orange</product_description>        <product_quantity>1</product_quantity>    </product>    <product>        <Id>4</Id>        <product_name>apple</product_name>        <product_price>4.00</product_price>        <product_description>its apple</product_description>        <product_quantity>1</product_quantity>    </product></productdetails>我想做的是將它們存儲(chǔ)回另一個(gè)不同但臨時(shí)的 xml 文件中,然后在 GridView 中進(jìn)行計(jì)算。
查看完整描述

1 回答

?
函數(shù)式編程

TA貢獻(xiàn)1807條經(jīng)驗(yàn) 獲得超9個(gè)贊

希望我正確理解您的詢問(wèn)。您可以使用 Linq 根據(jù)其 Id 搜索特定數(shù)據(jù)。例如,


var root = XElement.Parse(xmlString);  

var idToSearch = 1;

var result= root.Elements("product")

                .Where(x=>Convert.ToInt32(x.Element("Id").Value)==idToSearch)

                .Select(x=>new 

                           {

                             ProductName=x.Element("product_name").Value,

                             Price=x.Element("product_price").Value

                           });


查看完整回答
反對(duì) 回復(fù) 2023-12-17
  • 1 回答
  • 0 關(guān)注
  • 203 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)