I got the following XML code, which is variable. This XML must be converted into a multidimensional dictionary.
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<root>
<functie>create-jounalentry</functie>
<klantid>506</klantid>
<dagboek>1300</dagboek>
<datum>1/21/2014</datum>
<omschrijving>Blaat B.V., SXS1000549</omschrijving>
<factuurnummer>SXS1000549</factuurnummer>
<regel>
<grootboeknr>1300</grootboeknr>
<omschrijving></omschrijving>
<debit>121</debit>
<credit>0</credit>
</regel>
</root>
I use the follwing code for a standard XML code, which works great. But it does not work with the extra layer "". The elements are variable, so I can not select on "", because I don't know its value in the real code.
// Parsing XML to array
XElement aValues = XElement.Parse(sMessage);
var oValues = aValues.Descendants().ToDictionary(x => x.Name.LocalName, x => (object)x.Value);
I can read the above as oValues["functie"] etc..
Is it possible to read the extra layer in the same dictionary as oValues["regel"]["grootboeknr"] etc.?
Thanks in advance!
No comments:
Post a Comment