efryevt
asked on
Searching/Editing XML using Linq
I have some XML(see below) that I want to parse using Linq in C#.NET. I want to:
1. Count the number of hardware nodes
2. Read the value for each CardID under each Hardware node
3. Change the CardModel value under each Hardware node
I apologize for this over simplified version of what I am trying to accomplish, but I believe this hits on all the points.
I have tried the following code to simply count the hardware nodes, but the query contains no elements.
1. Count the number of hardware nodes
2. Read the value for each CardID under each Hardware node
3. Change the CardModel value under each Hardware node
I apologize for this over simplified version of what I am trying to accomplish, but I believe this hits on all the points.
I have tried the following code to simply count the hardware nodes, but the query contains no elements.
XElement root = XElement.Load(myXMLPath);
var query = from c in root.Elements("Hardware")
select c;
Example XML<MyDataSet xmlns="http://tempuri.org/MyDataSet.xsd">
<Hardware>
<CardID>0</CardID>
<CardPCISlot>0</CardPCISlot>
<CardModel>130</CardModel>
</Hardware>
<Hardware>
<CardID>1</CardID>
<CardPCISlot>2</CardPCISlot>
<CardModel>145</CardModel>
</Hardware>
</MyDataSet>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Question closed.
ASKER