This is one possible solution, however if it is exactly what you want is difficult for me to say with the little information you have provided.
The resulting XML structure is just a guesstimate and might not suit your needs.
First read the whole contents of the file into a string.
(If the file is very big, this approach might not be the best)
string content = File.ReadAllText(<filename>);</filename>
Then use this regular expression on the content:
Regex expression = new Regex(@"##(?<parent>\w+)\r\n(?<children>[\w ]+)\r\n((?<values>[\S ]+)(\r\n(?!#)|$))+", RegexOptions.None);
This expression will give you three named groups where of the 'values' group has one or more captures.
Then loop through all matches and create the XML structure.
I have used XElement, but XmlDocument can also be used.
XElement xeRoot = new XElement("root");
foreach (Match m in expression.Matches(content))
{
XElement xeParent = new XElement(m.Groups["parent"].Value);
string[] children = m.Groups["children"].Value.Split(' ');
foreach (Capture cap in m.Groups["values"].Captures)
{
XElement xeChild = new XElement("child");
string[] values = cap.Value.Split(new string[] { "@*@" }, StringSplitOptions.None);
if (children.Length != values.Length)
throw new Exception("The number of children and values mismatch.");
for (int i = 0; i < children.Length; i++)
{
XElement xeChildValue = new XElement(children[i]);
xeChildValue.Value = values[i];
xeChild.Add(xeChildValue);
}
xeParent.Add(xeChild);
}
xeRoot.Add(xeParent);
}
Finally save the XML data to file
XDocument doc = new XDocument();
doc.Add(xeRoot);
doc.Save(@"C:\Temp\test.xml");
Resulting XML
="1.0"="utf-8"
<root>
<Main>
<child>
<MachineName>RMM-LT-417</MachineName>
<DomainName>Home.LOCAL</DomainName>
<Scandate>03/23/2015 18:48:38</Scandate>
<GUID>31c0841e-f7bf-4de1-9d75-7e9080498e6b-20141216020243430495</GUID>
<RegID>2853625</RegID>
</child>
</Main>
<AP_LogicalDrivesInformation>
<child>
<Caption>C</Caption>
<Description>Hard Drive</Description>
<DriveType>Drive Fixed</DriveType>
<FileSystem>NTFS</FileSystem>
<FreeSpace>421002715136</FreeSpace>
<UsedSpace>79097778176</UsedSpace>
<Size>500100493312</Size>
<CFreeSpace>392.1 GB</CFreeSpace>
<CUsedSpace>73.7 GB</CUsedSpace>
<VolumeName>OS</VolumeName>
<VolumeSerialNumber>469D6D66</VolumeSerialNumber>
</child>
<child>
<Caption>D</Caption>
<Description>Hard Drive</Description>
<DriveType>Drive Fixed</DriveType>
<FileSystem>NTFS</FileSystem>
<FreeSpace>484706508800</FreeSpace>
<UsedSpace>4765618176</UsedSpace>
<Size>489472126976</Size>
<CFreeSpace>451.4 GB</CFreeSpace>
<CUsedSpace>4.4 GB</CUsedSpace>
<VolumeName>DATAPART</VolumeName>
<VolumeSerialNumber>7A9EDCCC</VolumeSerialNumber>
</child>
<child>
<Caption>E</Caption>
<Description>MATSHITA DVD+-RW UJ8E2</Description>
<DriveType>Cd-Rom</DriveType>
<FileSystem></FileSystem>
<FreeSpace>0</FreeSpace>
<UsedSpace>0</UsedSpace>
<Size>0</Size>
<CFreeSpace>0</CFreeSpace>
<CUsedSpace>0</CUsedSpace>
<VolumeName></VolumeName>
<VolumeSerialNumber>0</VolumeSerialNumber>
</child>
</AP_LogicalDrivesInformation>
</root>