C# linq to xml, nested query with attributes

delboy0

New Member
Im really struggling to get my head round this.Im using c#.I want to get back an IEnumerable of products from an xml file.Below is a sample of the xml structure.I need to get a list of products that have the productEnriched custom attribute set as true.Some products wont have any custom attribute section at allmy head has strated to hurt just thinking about it!\[code\]<?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>\[/code\]thanks for any helpTo clear things up i have added a few more items to the example xmlI need to get a list of productsonly products that have a custom-attribute element with the attribute productEnriched and value of truesome products in the xml wont have any custom-attribute or custom-attributes elementssome products will have it but with a value of falsei just need a list of products where it exists and has a value of true\[code\]<?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>\[/code\]
 
Back
Top