c# - cast or convert XmlNodeList to XmlNode -


im having issue code , hoping assistance you. have method of type xmlnodelist (getdetailpagesectionbysa), method used 1 of parameters in method. method (getserviceaccountusageandbillingdetail) expecting type of xmlnode parameter(sadetailedpagenode). if change data type xmlnodelist parameter messes whole bunch of stuff down line xmlnode can used.

why dont change type of first method (getdetailpagesectionbysa) xmlnode , solve issues ask? because type can return 1 node , method returns collection of nodes , needs use xmlnodelist.

so im wondering if there ways convert or cast xmlnodelist xmlnode , if how done?

foreach (getbillforcaresponse ebillresponse in ebillresponselist) {    var statementdetailsresponse = getstatementdetails(        new getstatementdetailsrequest        {            batchid = ebillresponse.batchid,            customeraccountid = ebillresponse.ca.tostring("000000000"),            statementid = ebillresponse.cas_num.tostring("0000")        });     string xmlbill = statementdetailsresponse.statementasxml.tostring();    var document = new xmldocument();    document.loadxml(xmlbill);     ****var sadetailedpagenode = xmlbillparser.getdetailpagesectionbysa(requestsa, xmlbill);// method of type xmlnodelist    if (sadetailedpagenode == null) continue;     var customerbill = new customerbill();    customerbill.issurepay = xmlbillparser.getsurepayflagfrombill(document);    customerbill.serviceaddress = xmlbillparser.getserviceaddress(requestsa, document);    customerbill.monthname = xmlbillparser.getbillstatementdate(requestsa, xmlbill);    customerbill.eqcurplanbal = xmlbillparser.getequalizercurrentplanbalance(document);    customerbill.eqpymntdue = xmlbillparser.getequalizerpaymentdue(document);     ****customerbill.service = getserviceaccountusageandbillingdetail(requestsa, xmlbill, sadetailedpagenode);// invalid argument because sadetailedpagenode should of type xmlnode    response.add(customerbill); } 

i have put **** issue comments on lines. beginner in coding , great. in advanced.

there no such thing casting xmlnodelist xmlnode. xmlnodelist is, name suggests, list of xmlnodes. so, if want xmlnodes in list, have go through list , perform action on every node in list.

in case, suspect getdetailpagesectionbysa return multiple sections bill. if so, add foreach loop:

foreach (getbillforcaresponse ebillresponse in ebillresponselist) {    // removed code brevity     foreach(var sadetailedpagenode =x mlbillparser.getdetailpagesectionbysa(requestsa, xmlbill)    {        var customerbill = new customerbill();        customerbill.issurepay = xmlbillparser.getsurepayflagfrombill(document);        customerbill.serviceaddress = xmlbillparser.getserviceaddress(requestsa, document);        customerbill.monthname = xmlbillparser.getbillstatementdate(requestsa, xmlbill);        customerbill.eqcurplanbal = xmlbillparser.getequalizercurrentplanbalance(document);        customerbill.eqpymntdue = xmlbillparser.getequalizerpaymentdue(document);         customerbill.service = getserviceaccountusageandbillingdetail(requestsa, xmlbill, sadetailedpagenode)        response.add(customerbill);     } } 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -