Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8648073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:13:50+00:00 2026-06-12T13:13:50+00:00

This is my XML file: <?xml version=1.0 encoding=utf-8?> <test xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:xsd=http://www.w3.org/2001/XMLSchema> <name>test</name> <one>1</one> <two>2</two>

  • 0

This is my XML file:

<?xml version="1.0" encoding="utf-8"?>
<test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <name>test</name>
 <one>1</one>
 <two>2</two>
</test>

And this is my code:

Imports System.Xml.Serialization
Imports System.IO

Class main

Sub Main()
    Dim p As New test()

    Dim x As New XmlSerializer(p.GetType)

    Dim objStreamReader As New StreamReader("XML.xml")
    Dim p2 As New class1()
    p2 = x.Deserialize(objStreamReader)
    objStreamReader.Close()

    MsgBox(p2.name)
    MsgBox(p2.one)
    MsgBox(p2.two)

End Sub

End Class

And my classes:

Imports System.Xml.Serialization

Public Class test

Private newname As String
Private newone As Integer
Private newtwo As Integer

Public Property name() As String
    Get
        name = newname
    End Get
    Set(ByVal value As String)
        newname= value
    End Set
End Property

Public Property one() As Integer
    Get
        one = newone
    End Get
    Set(ByVal value As Integer)
        newone = value
    End Set
End Property

Public Property two() As Integer
    Get
        two = newtwo
    End Get
    Set(ByVal value As Integer)
        newtwo = value
    End Set
End Property

End Class

It works, it gives me the Message Boxes with the data in the XML file, I’m having trouble however, if I add inner nodes to the XML file like this:

<?xml version="1.0" encoding="utf-8"?>
<test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <name>test</name>
 <numbers>
  <one>1</one>
  <two>2</two>
 </numbers>
</test>

How am I supposed to work numbers out? I know it’s a property of test, but it’s also a class because it has one and two as properties, so what would the right approach be?

Update:

<?xml version="1.0" encoding="utf-8"?>
<test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <name>test</name>
 <numbers>
  <one>1</one>
  <two>2</two>
 </numbers>
 <numbers>
  <one>3</one>
  <two>4</two>
 </numbers>
</test>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:13:51+00:00Added an answer on June 12, 2026 at 1:13 pm

    To deserialize that example XML, you’d want your data classes to look like this:

    Public Class test
        Private newname As String
        Private newnumbers As List(Of Numbers)
    
        Public Property name() As String
            Get
                Return newname
            End Get
            Set(ByVal value As String)
                newname = value
            End Set
        End Property
    
        <XmlElement()> _
        Public Property numbers() As List(Of Numbers)
            Get
                Return newnumbers
            End Get
            Set(ByVal value As List(Of Numbers))
                newnumbers = value
            End Set
        End Property
    End Class
    
    Public Class Numbers
        Private newone As Integer
        Private newtwo As Integer
    
        Public Property one() As Integer
            Get
                Return newone
            End Get
            Set(ByVal value As Integer)
                newone = value
            End Set
        End Property
    
        Public Property two() As Integer
            Get
                Return newtwo
            End Get
            Set(ByVal value As Integer)
                newtwo = value
            End Set
        End Property
    End Class
    

    Then you could deserialize it like this:

    Sub Main()
        Dim p As New test()
        Dim x As New XmlSerializer(p.GetType)
        Dim objStreamReader As New StreamReader("XML.xml")
        Dim p2 As New test()
        p2 = x.Deserialize(objStreamReader)
        objStreamReader.Close()
        MsgBox(p2.name)
        For Each i As Numbers In p2.numbers
            MsgBox(i.one)
            MsgBox(i.two)
        Next
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this xml file <?xml version=1.0 encoding=UTF-8?> <bo:C837ClaimParent xsi:type=bo:C837ClaimParent xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:bo=http://somelongpathHere/process/bo> <claimAux> ...
I have a Xml-Schema file to validate xml-Files. Xml-Schema: <?xml version=1.0 encoding=UTF-8?> <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema
Here is my test context <?xml version=1.0 encoding=UTF-8?> <beans xmlns=http://www.springframework.org/schema/beans xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:mvc=http://www.springframework.org/schema/mvc xmlns:p=http://www.springframework.org/schema/p xmlns:aop=http://www.springframework.org/schema/aop
I have this XML at http://localhost/file.xml : <?xml version=1.0 encoding=utf-8?> <val:Root xmlns:val=http://www.hw-group.com/XMLSchema/ste/values.xsd> <Agent> <Version>2.0.3</Version>
Say I have an XML file which looks like this: <?xml version=1.0 encoding=UTF-8?> <Project
Hi I can't understand this error I want read this XML file: <?xml version=1.0
I have the next element <statement id =5> insert into TBTEMPLATES(CTDB_LAST_UPDATOR) values('<?xml version=1.0 encoding=UTF-8?><Interface
i try to make declarative transaction work. This is my spring.xml file: <?xml version=1.0
A little help needed. I'm receiving an xml file similar to this: <?xml version=1.0
With this XML file - <Instructions> <Admin> <Instruction> Steps must be completed in order.&lt;/br&gt;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.