I am new in Linq to xml. My xml string is as follows :
<root>
<add>
<item id="jqg1" moduleid="F0736590-84A2-4795-BC5D-0056606F2446" view="1" add="1" edit="0" del="0" />
</add>
<update>
<item id="jqg3" moduleid="3C414435-DBBE-4B4E-A790-14B67F050EB0" view="1" add="1" edit="1" del="0" />
</update>
</root>
coming from jquery to C# which is placed inside texbox(textbox Visible = false).
NOTE : element could be more than one in every and element.
Code to read xml string in C# on button click eevnt.
string paramXML = txtXmlStr.Text;
var l_sID = "";
var l_sMODID = "";
var l_sVIEW = "";
var l_sADD = "";
var l_sEDIT = "";
var l_sDEL = "";
if (!string.Empty.Equals(paramXML))
{
var l_oXDoc = XDocument.Parse(paramXML.ToLower());
==> var addParams = from addParam in l_oXDoc.Element("add").Elements("item")
select new
{
l_sID = addParam.Attribute("id").Value,
l_sMODID = addParam.Attribute("moduleId").Value,
l_sVIEW = addParam.Attribute("view").Value,
l_sADD = addParam.Attribute("add").Value,
l_sEDIT = addParam.Attribute("edit").Value,
l_sDEL = addParam.Attribute("del").Value,
};
foreach (var oParam in addParams)
{
string id = oParam.l_sID.Trim();
string modid = oParam.l_sMODID.Trim();
string view = oParam.l_sMODID.Trim();
string add = oParam.l_sMODID.Trim();
string edit = oParam.l_sMODID.Trim();
string del = oParam.l_sMODID.Trim();
}
I am getting above error on arrow which I already specified in code. How should I resolve this error???
*NOTE:*My goal is to read <Add>
element's <item>
element data into one variable and I also want to do same for <update>
element. Is that possible.... everyones suggestion, ideas and code is welcome....