亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何從 Linq 查詢中保存多個特定的子元素?

如何從 Linq 查詢中保存多個特定的子元素?

C#
繁星coding 2021-08-07 15:58:37
XML 文件如下所示<osm version="0.6" generator="CGImap 0.0.2">  <bounds minlat="54.0889580" minlon="12.2487570" maxlat="54.0913900" maxlon="12.2524800"/>  <node id="298884269" lat="54.0901746" lon="12.2482632" user="SvenHRO" uid="46882" visible="true" version="1" changeset="676636" timestamp="2008-09-21T21:37:45Z"/>  <node id="261728686" lat="54.0906309" lon="12.2441924" user="PikoWinter" uid="36744" visible="true" version="1" changeset="323878" timestamp="2008-05-03T13:39:23Z"/>  <way id="11103644" visible="true" version="22" changeset="57021161" timestamp="2018-03-09T06:06:21Z" user="thetornado76" uid="1624486">   <nd ref="5058358201"/>   <nd ref="5058358200"/>   <nd ref="459672758"/>   <nd ref="459672757"/>   <nd ref="459672756"/>   <tag k="bicycle" v="no"/>   <tag k="destination" v="Airport"/> </way> <way id="11103973" visible="true" version="1" changeset="410956" timestamp="2007-11-05T15:10:28Z" user="DaveHansenTiger" uid="7168">   <nd ref="98983980"/>   <nd ref="98983981"/>   <tag k="tiger:source" v="tiger_import_dch_v0.6_20070809"/>   <tag k="tiger:tlid" v="116306702"/>   <tag k="tiger:upload_uuid" v="bulk_upload.pl-bcfe2a6c-15d8-4c58-8cb2-f0d6e1120159"/> </way></osm>這是我到目前為止//Removes the "tag" element from xmlosmFile.Root.Elements().Elements().Where(x => x.Name == "tag").Remove();//Each iteration of query has the an entire <way> elements and all its childrenvar query = from c in osmFile.Root.Elements("way")            select c;我的問題是,如何才能使遍歷查詢的每次迭代僅具有特定方式的 nd 元素的所有屬性值?例如,如果我這樣做foreach (var x in query)    MessageBox.Show(x.ToString());第一次迭代將顯示50583582015058358200459672758459672757459672756第二個會顯示9898398098983981另外,有沒有辦法在不首先刪除所有標簽元素的情況下實現這一點?
查看完整描述

2 回答

  • 2 回答
  • 0 關注
  • 187 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號