in Education by
I have this XML file and am able to read it, but it breaks and returns null once it gets to the item tags. NOTE: I only included the XML snippet that is giving me problems. 2019-03-12 1 ERP posting error (ERP integration timeout): Posted by Service User filemanager.su@100039144 File Manager File Manager 0 filemanagersprocess.su@100039144 File Manager File Manager 3746.29 UTILITIES DEEK WAREHOUSE 66999939393 12345 Jimmy Johns KL 0 (SALES) 0 Currently my class setup is: namespace XmlDeserializer { [XmlRoot(ElementName = "ApproversList")] public class ApproversList { [XmlElement(ElementName = "item")] public Item Item { get; set; } } [XmlRoot(ElementName = "item")] public class Item { [XmlElement(ElementName = "ApprovalDate")] public string ApprovalDate { get; set; } [XmlElement(ElementName = "Approved")] public string Approved { get; set; } [XmlElement(ElementName = "ApproverComment")] public string ApproverComment { get; set; } [XmlElement(ElementName = "ApproverEmail")] public string ApproverEmail { get; set; } [XmlElement(ElementName = "ApproverID")] public string ApproverID { get; set; } [XmlElement(ElementName = "ApproverLabelRole")] public string ApproverLabelRole { get; set; } [XmlElement(ElementName = "Approver")] public string Approver { get; set; } [XmlElement(ElementName = "Amount")] public string Amount { get; set; } [XmlElement(ElementName = "Assignment")] public string Assignment { get; set; } [XmlElement(ElementName = "BusinessArea")] public string BusinessArea { get; set; } [XmlElement(ElementName = "CCDescription")] public string CCDescription { get; set; } [XmlElement(ElementName = "CostCenter")] public string CostCenter { get; set; } [XmlElement(ElementName = "DeliveryNote")] public string DeliveryNote { get; set; } [XmlElement(ElementName = "Description")] public string Description { get; set; } [XmlElement(ElementName = "GLAccount")] public string GLAccount { get; set; } [XmlElement(ElementName = "GLDescription")] public string GLDescription { get; set; } [XmlElement(ElementName = "GoodReceipt")] public string GoodReceipt { get; set; } [XmlElement(ElementName = "InternalOrder")] public string InternalOrder { get; set; } [XmlElement(ElementName = "ItemNumber")] public string ItemNumber { get; set; } [XmlElement(ElementName = "LineType")] public string LineType { get; set; } [XmlElement(ElementName = "OrderNumber")] public string OrderNumber { get; set; } [XmlElement(ElementName = "Quantity")] public string Quantity { get; set; } [XmlElement(ElementName = "TaxAmount")] public string TaxAmount { get; set; } [XmlElement(ElementName = "TaxCode")] public string TaxCode { get; set; } [XmlElement(ElementName = "TaxJurisdiction")] public string TaxJurisdiction { get; set; } [XmlElement(ElementName = "TaxRate")] public string TaxRate { get; set; } } } Code that deserializes XML: public static void DeserializeToObject(out Invoice invoice) { XmlSerializer serializer = new XmlSerializer(typeof(Invoice)); invoice = new Invoice(); using (FileStream fileStream = new FileStream(@"FILEPATH", FileMode.Open)) { Invoice result = (Invoice)serializer.Deserialize(fileStream); } } I have tried multiple possible solutions and can't get it to work correctly. This is my last resort. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
items is a collection. Change your class to: [XmlRoot(ElementName = "ApproversList")] public class ApproversList { [System.Xml.Serialization.XmlElementAttribute("item")] public Item[] Item { get; set; } } Future tip, copy the XML, go to Visual Studio, in a new C# file, click Edit -> Paste Special -> Paste XML as Classes

Related questions

0 votes
    Is there a built in dll that will give me a list of links from a string. I want to send in ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    I have one aspx page with 1000 anchor tag. I want to open single popup onclick of anchor tag & ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 20, 2022 in Education by JackTerrance
0 votes
    Greetings! I'm working on wrapping my head around LINQ. If I had some XML such as this loaded ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 13, 2022 in Education by JackTerrance
0 votes
    I have many rows in a database that contains XML and I'm trying to write a Python script that will go through ... the XML using Python? Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I am receiving SOAP requests from a client that uses the Axis 1.4 libraries. The requests have the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 30, 2022 in Education by JackTerrance
0 votes
    I am receiving SOAP requests from a client that uses the Axis 1.4 libraries. The requests have the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 29, 2022 in Education by JackTerrance
0 votes
    Designing a registration form, and I get this error when adding in MessageBoxButtons and MessageBoxIcon. The error ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 15, 2022 in Education by JackTerrance
0 votes
    Designing a registration form, and I get this error when adding in MessageBoxButtons and MessageBoxIcon. The error ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
0 votes
    I want to make a method that will populate the lst_List list with rows from various tables and fields. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    I want to make a method that will populate the lst_List list with rows from various tables and fields. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    In my tests I need to test what happens when an OracleException is thrown (due to a stored procedure ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 23, 2022 in Education by JackTerrance
0 votes
    How would you test this scenario? I've just started looking into NHibernate and having my first bash at ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    Is there any way to convert following SQL statement into LINQ? select ve.EntityID , fin1.FinanceStat as ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 23, 2022 in Education by JackTerrance
0 votes
    I am trying to set text and value for both td tag and input tag at the same time. But after ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    I am trying to set text and value for both td tag and input tag at the same time. But after ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
...