0

I am wondering how I can map an XML file to C# objects.

This is my XML File:

<MyXML>
    <Suppliers>
        <Supplier 
            SupplierID="1" 
            SupplierName="Test" 
            SupplierContact="Test" 
            SupplierPhone="0612345678" 
            SupplierEmail="[email protected]" 
            SupplierAddress="Test" 
            SupplierSuburb="Test" 
            SupplierPostcode="1234QE"></Supplier>
    </Suppliers>
    <Genres>
        <Genre 
        GenreID="1" 
        GenreName="Test"></Genre>
    </Genres>
    <Authors>
        <Author 
        AuthorID="1" 
        AuthorName="Test" 
        AuthorSurName="Test" 
        AuthorPlaceOfBirth="Test" 
        AuthorDoB="2000-07-06"></Author>
    </Authors>
    <Publishers>
        <Publisher 
        PublisherID="1" 
        PublisherName="Test" 
        PublisherContact="Test" 
        PublisherPhone="Test" 
        PublisherEmail="Test" 
        PublisherAddress="Test" 
        PublisherSuburb="Test" 
        PublisherPostcode="Test"></Publisher>
    </Publishers>
    <Inventories>
        <Inventory 
        InventoryID="1" 
        Title="Test" 
        WholeSale="Test" 
        MarkUp="Test" 
        Discount="Test" 
        QuantityInStock="Test" 
        GenreID="1" 
        SupplierID="1"></Inventory>
    </Inventories>
    <Books>
        <Book 
        InventoryID="1" 
        PublishYear="2000-10-10" 
        CoverType="Test" 
        PublisherID="1"></Book>
    </Books>
    <Author_Books>
        <Author_Book 
        AuthorID="1" 
        InventoryID="1"></Author_Book>
    </Author_Books>
    <Customers>
        <Customer 
        CustomerID="1" 
        CustomerName="Test" 
        CustomerSurname="Test" 
        CustomerPhone="0612345678" 
        CustomerEmail="Test" 
        CustomerAddress="Test" 
        CustomerPostcode="Test" 
        CustomerDiscount="100"></Customer>
    </Customers>
    <Receipts>
        <Receipt 
        ReceiptID="1" 
        CustomerID="1" 
        Date="2018-04-01"></Receipt>
    </Receipts>
    <Purchases>
        <Purchase 
        ReceiptID="1" 
        InventoryID="1" 
        Quantity="3" 
        AmountPaid="91"></Purchase>
    </Purchases>
</MyXML>

I just have no clue how I can map this to objects. This is because it contains data from multiple tables. I was thinking of datasets, but what is the best way of doing this? I have looked around, but no one really explains their awnser.

9

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.