I Have an XML file like the one below:
<?xml version="1.0" ?>
<System>
<LP1>
<Equipment>
<FromName>Receptacle</FromName>
<Wire>1-#10, 1-#10, 1-#10</Wire>
<Length>89.8411846136344</Length>
</Equipment>
</LP1>
<X-1>
<Equipment>
<FromName>LP1</FromName>
<Wire>3-#3/0, 1-#3/0, 1-#6</Wire>
<Length>10.170412377555</Length>
</Equipment>
</X-1>
<HP1>
<Equipment>
<FromName>X-1</FromName>
<Wire>3-#3/0, 1-#3/0, 1-#6</Wire>
<Length>8.2423259796908</Length>
</Equipment>
<Equipment>
<FromName>AH-1</FromName>
<Wire>3-#6, 1-#10</Wire>
<Length>32.4019419736209</Length>
</Equipment>
<Equipment>
<FromName>EF-1</FromName>
<Wire>3-#12, 1-#12, 1-#12</Wire>
<Length>8.33572105849677</Length>
</Equipment>
</HP1>
</System>
I need to read it, and re-arrange it to look:
<?xml version="1.0" ?>
<HP1>
<Equipment>
<FromName>X-1</FromName>
<Wire>3-#3/0, 1-#3/0, 1-#6</Wire>
<Length>8.2423259796908</Length>
<Equipment>
<FromName>LP1</FromName>
<Wire>3-#3/0, 1-#3/0, 1-#6</Wire>
<Length>10.170412377555</Length>
<Equipment>
<FromName>Receptacle</FromName>
<Wire>1-#10, 1-#10, 1-#10</Wire>
<Length>89.8411846136344</Length>
</Equipment>
</Equipment>
</Equipment>
<Equipment>
<FromName>AH-1</FromName>
<Wire>3-#6, 1-#10</Wire>
<Length>32.4019419736209</Length>
</Equipment>
<Equipment>
<FromName>EF-1</FromName>
<Wire>3-#12, 1-#12, 1-#12</Wire>
<Length>8.33572105849677</Length>
</Equipment>
</HP1>
</System>
Basically, the original XML has separate Elements (LP1, X-1, HP1) that I want to put as sub elements when the equipment "FromName" matches the parent element name of the system.
I am guessing that I will need to do some recursive function, but I am kind of new to C# and programming in general and haven't had much experience with XML or recursive function.
Any help would be appreciated.
Thank you