我真的很难理解这个。
我正在使用c#。
我想从一个xml文件中获取一个产品的IEnumerable列表。
以下是xml结构的示例。
我需要获取一个产品列表,其中productEnriched自定义属性设置为true。
有些产品根本没有任何自定义属性部分
仅考虑这个问题我的头就开始疼了!
<?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中添加了更多项目
我需要获取产品列表 仅包含具有自定义属性元素且属性productEnriched的值为true的产品 XML中的某些产品将没有任何自定义属性或自定义属性元素 某些产品会有它,但其值为false 我只需要存在并具有true值的产品列表
<?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>
<custom-attribute attribute-id="productEnriched">true</custom-attribute>
?至少<custom-attribute productEnriched="true">
有什么问题吗? - Konrad Morawski