If I was retrieving a single element, I can use to pull an element named Name.
<li><span>System Name:</span>@(Model.Configuration.Root.Element("Name").Value)</li>
But, when I have multiple elements with the same name, it tells me Sequence contains no elements even though if I do it from code-behind, it gives me elements.
XML file:
<root>
<Port Num="1">
<Device>
<Firmware>1.0</Firmware>
</Device>
</Port>
<Port Num="2">
<Device>
<Firmware>1.0</Firmware>
</Device>
</Port>
</root>
CSHTML file:
<li><span>Port: 1</span>Firmware: @(
Model.Configuration.Root.Elements("Port")
.Where(a=>a.Attribute("Num").Equals("1")).First()
.Element("Device").Element("Firmware").Value)</li>
I want to retrieve the Firmware number (1.0) from Port #1.