我真的很努力想要讓我的頭轉過來。C#linq to xml,具有屬性的嵌套查詢
我正在使用c#。
我想從一個XML文件中找回IEnumerable的產品。
下面是XML結構的樣品。
我需要的是具有設置爲如真productEnriched自定義屬性的產品列表。
有些產品不會有根本
我頭上的任何自定義屬性部分已經strated傷想到它!
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns="http://www.mynamespace.com" catalog-id="MvgCatalog">
<product>
<custom-attributes>
<custom-attribute attribute-id="productEnriched">true</custom-attribute>
</custom-attributes>
</product>
</category>
感謝您的幫助
要澄清一些事情我已經增加了一些更多的項目到示例XML
我需要的產品 只是有一個定做的產品列表屬性元素用在XML productEnriched屬性和真實 一些產品的價值不會有任何自定義屬性或自定義屬性的元素 一些產品會有,但與假 值我只是需要的地方存在的產品列表一個第二有真正
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns="http://www.mynamespace.com" catalog-id="MvgCatalog">
<product>
<upc>000000000000</upc>
<productTitle>My product name</productTitle>
<custom-attributes>
<custom-attribute attribute-id="productEnriched">true</custom-attribute>
<custom-attribute attribute-id="somethingElse">4</custom-attribute>
<custom-attribute attribute-id="anotherThing">otherdata</custom-attribute>
</custom-attributes>
</product>
</category>
爲什麼'<自定義屬性屬性ID = 「productEnriched」>真定製屬性>'? (至少)''? –
我必須拉出具有值爲true的嵌套自定義屬性的產品列表。我不明白爲什麼問題抱歉?我已經嘗試了所有我能想到的,讓我自己瘋狂的舞臺!即時通訊新的C#/ LINQ這不是太多幫助! – Pete