Creating an XML document using in-memory collection of objects - XML Tutorial
Автор: Duong Thanh Doanh
Загружено: 2020-11-01
Просмотров: 66
Описание:
Creating an XML document using in-memory collection of objects is a free tutorial by Venkat Kud from XML course
Link to this course(Special Discount):
https://www.udemy.com/course/linq-to-...
This is the best XML Course
Course summary:
By the end of this course you will be able to write effective LINQ queries
English [Auto]
This is part tootling flexible to Dorio And this video will discuss creating an XML document using in-memory collection of objects in part one of this video series we discussed creating this XML document by hard coding these ex-MIL elements in court. If you recollect example that we worked with in the previous video session not is that student data is hardcoded within the application in real time applications data usually resides in a database table that has several data access technologies that are available today to retrieve data from the database. For example we could use dot net or linked to sequel or Entity Framework. Once the application has to retrieve data from the database then the application may use data structures like a race list queues etc. to store that data in memory for processing for the purpose of this demo. Let's assume that you already have this tool indeed or two from the database and the application is storing it in an ID. And now what we want to do is clear this X-No document from that idea of student objects you think Link X-amount. So let's see how to achieve this. Let's flip to Visual Studio. So does the same example that we worked with in the previous video session. The first thing that you're going to do here is add a class to this project and let's name this student. Dodd C-s to speed things up. I have already implemented the code required for this class. So let's copy it from the notepad and paste it within this class. So this class is straightforward. Here we've got four properties ID name gender and watermarks. In addition we also have this get all students method which returns an array of student objects and within a matter of creating a student at a Harvard is initialized to 4. Which means we can store full student objects within the data. And here are the doors for student objects and the method. Finally returns that idea back in reality people have $8.9 linked to sequela some sort of data access called here to retrieve this data from the database but to keep things simple I've just hardcoded student data within this method. So now what we want to do is whatever student objects that this method is returning. We want to use linked to X-amount and convert these students into an ex-MIL document. So let's see how to achieve that. So within our main method so discord is going to stay the same. So we still need the ex-MIL declaration. We still need that simple comment and that the root element within the X-amount is going to be students and then but then students will tell them and we got student detailed elements and each student change and has got name gender and total marks child elements. So we want to create the same kind of structure. So because until here it's not going to change. Let's remove this hardcoded student data from here and I'm going to keep these two closing brackets here because the first closing bracket is actually going to close this element and the second closing bracket closes this XML document constructor. OK. So here we are going to write a query. So let's bring in system dot link namespace System dog link and let's call the variable student n we have a student class. Get all students with this method is going to give us a model of student objects. So what we want to do with that student object is selecting new X element. So here is that students element within that we wanted taled student element and student element has got an ID attribute. So we are going to create a new instance of X attributes or this class help us create the X-amount attribute. So the name of the attribute is going to be ID. Now where are we going to get the student ID from from this student object. So student dart ID property should give us that. And each student element has got name name gender and total elements. OK so we are going to create an instance of X element again and then the name of the element is going to be in name and we need to get a student name. So for that we're going to use the student object again and then use the name property. Similarly be one gender and total marks so gender and be going to use the gender property of the student object. And finally talk to you Max. Right. So we're going to close this student element here discloses the root element and discloses the final ex-MIL document. So that's all there to it. So what is this going to do. It's going to take each student object and then create a student element on a student
Повторяем попытку...

Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: