asp.net - Getting error while we add child node in Xdocument? -


am creating xml document using xdocument in asp.net.but getting error "object reference not set instance of object".in code ve line xdocele.element("input").addafterself(varxfilterele).

my sample xml file  <?xml version="1.0" encoding="utf-8" ?> 

<input>   <variable name="neospin.businessobjects.buspersonaccountsummary, neospinbusinessobjects" alias="person"/> </input>  <xfilterget name="data">   <single name="currentcontext">     <assign name="name" constant="active" />   </single>   <single name="snapshot">     <assign name="accountbalance" path="person.icdopersonaccountsummary.istrtotalintpluscontrformwp" />     <assign name="totalservicecredit" path="person.idectotalservice" />     <assign name="membershipdate" path="person.icdopersonaccountsummary.membership_begin_date" format="{0: mmm, dd yyyy}"/>     <assign name="status" path="person.icdopersonaccountsummary.drop_status_on_mss" />     <assign name="status1" constant="test" />   </single>   <single name="employeecontribution">     <assign name="taxedamount" path="person.icdopersonaccountsummary.total_taxed_contributions_amount" format="{0:c}" />     <assign name="untaxedamount" path="person.icdopersonaccountsummary.quarter_correction_total_untaxed_contributions_amount" format="{0:c}" />     <assign name="interest" path="person.icdopersonaccountsummary.quarter_correction_total_interest_amount" format="{0:c}" />   </single>   <single name="otherdetails">     <assign name="coveragegroup" path="person.istrserviceplandescription" />     <assign name="finalaveragesalary" path="person.icdopersonaccountsummary.fas" format="{0:c}" />   </single> </xfilterget> 

code generate xml file output below  <?xml version="1.0" encoding="utf-8"?>  -<xfilter>   -<input>  <variable alias="person"  name="neospin.businessobjects.buspersonaccountsummary,  neospinbusinessobjects"/>  </input>  </xfilter>   code ------   xelement xml = /*new xelement("users",*/                            new xelement("input",                            new xelement("variable", new xattribute("name",   textbox1.text), new xattribute("alias", textbox2.text))                             );             if (xdocele.descendants().count() > 0)                 xdocele.descendants().first().add(xml);              else             {                 xdocele.add(xml);              }             //xdocele.save("d:\\users.xml");              //httpcontext.current.cache.insert("xmlcacheitem", xdocele,  null, datetime.now.addminutes(5), cache.noslidingexpiration,  cacheitempriority.default, null);          //   cache.insert(key, value, nothing,          //cache.noabsoluteexpiration, timespan.fromseconds(10));             cache.insert("xmlcacheitem", xdocele, null,         datetime.now.addminutes(5),  system.web.caching.cache.noslidingexpiration);              xdocele = (xdocument)cache["xmlcacheitem"];              xdocele.save("d:\\users.xml");             xelement varxfilterele = new xelement("xfilterget", new  xattribute("name", "data"));             xdocele.element("input").addafterself(varxfilterele);             //cache.insert("xmlcacheitem", xdocele);              xelement varsingleele = new xelement("single", new  xattribute("name", textbox3.text));             xdocele.element("xfilterget").addafterself(varxfilterele);               xelement varassignele = new xelement("assign", new  xattribute("name", textbox3.text), new xattribute("name", textbox3.text),  new xattribute("name", textbox3.text));             xdocele.elements("single").where(item =>  item.attribute("name").value == textbox3.text).firstordefault()  .addafterself(varassignele);               cache.insert("xmlcacheitem", xdocele); 

in first addafterself method getting error .pls give me solution soive this?


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -