Read XML and create Objects using LINQ in VB.NET

Asked

Viewed 39 times

0

With the following code below:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <escuelas>
    <escuela>
    <estudiante>noe</estudiante>
    <fechaCreacion>2017-11-21T00:11:26.748-05:00</fechaCreacion>
    <idE>1</idE>
    <nombre>joao</nombre>
    <profesor>maria</profesor>
    </escuela>
    </escuelas>

Note: I am working with REST in a Web Service, so when adding a new object the service returns me an xml with all objects, however, I haven’t found a way to read this data yet.

1 answer

0


To work with XML vc you have some tools available in . Net Framework.
The Xpath and the Xmlserializer.
In Xmlserializer vc creates a class structure that corresponds to the XML structure you are loading, using annotations to determine whether values are in elements or attributes and calls the class’s Deserialize method to load all information to the structure you defined.

If what you want is simply to search for one or more specific values within Xml, Xpath is the right one. The link below explains how to use it:
https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/concepts/linq/how-to-filter-on-an-attribute-xpath-linq-to-xml

Abs and good work!

  • Thank you my dear, I have already solved my problem! Sorry I’m late, it was a college project so those who see this question and want to know how I solved, just call me ! Hugs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.