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

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

如何檢查某些沒有特定屬性的節(jié)點(diǎn)?

如何檢查某些沒有特定屬性的節(jié)點(diǎn)?

C#
回首憶惘然 2021-06-30 18:11:35
我有一些像下面這樣的 xml 文件<ref-list><ref id="ref1"><label>(1)</label> <mixed-citation publication-type="book" publication-format="print"><person-group person-group-type="author"><string-name><given-names>C.N.</given-names> <surname>Srinivasiengar</surname></string-name></person-group>, <source>The History of Ancient Indian Mathematics</source>. <publisher-loc>Calcutta</publisher-loc>: <publisher-name>The World Press</publisher-name>, <year>1967</year>.</mixed-citation></ref><ref id="ref2"><label>(2)</label> <mixed-citation publication-type="periodical" publication-format="print"><person-group person-group-type="author"><string-name><given-names>F.J.M.</given-names> <surname>Barning</surname></string-name></person-group>, <article-title>On Pythagorean and quasi-Pythagorean triangles and a generation process with the help of unimodular matrices</article-title>, <source type="IEEE">(Dutch) Math. Centrum Amsterdam Afd. Zuivere Wisk, ZW-011</source>, <year>1963</year>.</mixed-citation></ref>我正在嘗試檢查具有屬性Publication-type="thesis"的節(jié)點(diǎn)混合引用,并檢查它是否有任何名為機(jī)構(gòu)的子元素,其中沒有任何名為content-type 的屬性?;旧嫌胁荒芟袢魏喂?jié)點(diǎn)在混合引出版物型=“論文”但可以有。<institution>...</institution><institution content-type="...">...</institution>這是我試過的XDocument doc=XDocument.Load(xmlfile);var thesiss=doc.Descendants("mixed-citation")    .Where(a=>a.Attribute("publication-type").Value=="thesis")    .Where(a=>a.Descendants("institution").Any() && !a.Descendants("institution").Attributes("content-type").Any())    .Select(a=>a.Parent.Attribute("id"));foreach (var element in thesiss) {    Console.WriteLine("Check "+element);}但它并不完全按照我想要的方式工作。上面給出的樣本應(yīng)該給出輸出Check id="ref6"Check id="ref8"但它只顯示Check id="ref8"。請(qǐng)幫忙。
查看完整描述

1 回答

?
白衣非少年

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

將您的查詢更改為:


var thesiss = doc.Descendants("mixed-citation")

    .Where(a => a.Attribute("publication-type").Value == "thesis")

    .Where(a => !a.Descendants("institution").All(d => d.Attribute("content-type") != null))

    .Select(a => a.Parent.Attribute("id"));

這應(yīng)該會(huì)產(chǎn)生想要的結(jié)果。


查看完整回答
反對(duì) 回復(fù) 2021-07-03
  • 1 回答
  • 0 關(guān)注
  • 155 瀏覽

添加回答

舉報(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)