what is the best way to get attributes from xml files ?
I used regex but it's a bit pointless to extract the attributes.
<DataPacket Name="(.*)" Value="(.*)" Bit="(.*)"\/>
Group1 = Name
Group2 = Value
Group3 = Bit
<HeaderPacket Name="#Header">
<DataPacket Name="A" Value="1" Bit="7"/>
<DataPacket Name="B" Value="2" Bit="7"/>
</HeaderPacket>
<HeaderPacket Name="1">
<DataPacket Name="C" Value="17" Bit="16"/>
<DataPacket Name="L" Value="22" Bit="8"/>
</HeaderPacket>
Output I want to get:
Group1:
Header:
A 1 7
B 2 7
Group2:
1:
C 17 16
L 22 8
CodePudding user response:
This shows you how you can traverse and extract XML data in C# though.