I am trying to convert an XML data into dictionary. I am having problems with identical node names. C# .Net 3.5
Sample XML = the problem is I have no control over this.
just made this, works for me. bit clunky. use it as a template.
public static Dictionary RecDis(string ThisXML)
{
Dictionary ThisBlock = new Dictionary();
XElement doc = XElement.Parse(ThisXML);
XNode[] ThisNoideArray = doc.Nodes().ToArray();
foreach (XNode park in ThisNoideArray)
{
XElement parker = XElement.Parse(park.ToString());
if (parker.HasElements)
{
ThisBlock.Add(parker.Name.ToString(), RecDis(parker.ToString()));
}
else
{
ThisBlock.Add(parker.Name.ToString(), parker.Value.ToString());
}
}
return ThisBlock;
}