My code is as follows:
XDocument xmlDoc = XDocument.Load("myXML.xml");
var data = from items in xmlDoc.Root.Elements("category")
where items.Attribute("value").Value == "idxCategoryPlatformEngine"
select new
{
attribute = items.Element("attributes").Element("attribute").Element("name").Value,
trigger = items.Element("attributes").Element("attribute").Element("trigger").Value,
value = items.Element("attributes").Element("attribute").Element("value").Value,
minutes = items.Element("attributes").Element("attribute").Element("minutes").Value
};
The XML I have is as follows:
<?xml version="1.0" encoding="utf-8"?>
<GMS>
<category value="idxCategoryPlatformEngine">
<attributes>
<attribute>
<name>CheckpointFileCorruptionAlarm.InAlarm</name>
<trigger>EQ</trigger>
<value>TRUE</value>
<minutes>0</minutes>
</attribute>
<attribute>
<name>CPULoad</name>
<trigger>GT</trigger>
<value>60</value>
<minutes>5</minutes>
</attribute>
<attribute>
<name>Engine.Historian.InStoreForward</name>
<trigger>EQ</trigger>
<value>TRUE</value>
<minutes>0</minutes>
</attribute>
</attributes>
</category>
<category value="idxCategoryApplicationEngine">
<attributes>
<attribute>
<name>CheckpointFileCorruptionAlarm.InAlarm</name>
<trigger>EQ</trigger>
<value>TRUE</value>
<minutes>0</minutes>
</attribute>
<attribute>
<name>CPULoad</name>
<trigger>GT</trigger>
<value>60</value>
<minutes>5</minutes>
</attribute>
<attribute>
<name>Engine.Historian.InStoreForward</name>
<trigger>EQ</trigger>
<value>TRUE</value>
<minutes>0</minutes>
</attribute>
</attributes>
</category>
</GMS>
Now when I run the code it does perform the query however it only returns the first attribute where I actually want all attributes.
I'd appreciate any help on this as it is driving me crazy, each change I make to try fix this only results in more issues!