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 7163807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:57:53+00:00 2026-05-28T13:57:53+00:00

I am trying to write a class to serialize/deserialize something as simple as: <table

  • 0

I am trying to write a class to serialize/deserialize something as simple as:

<table border="1">
 <tr>
 <td>row 1, cell 1</td>
 <td>row 1, cell 2</td>
 </tr>
 <tr>
 <td>row 2, cell 1</td>
 <td>row 2, cell 2</td>
 </tr>
 </table> 

I have gotten to the point of (see below) but just can’t get it to generate the table xml correctly:

Imports System.Xml.Serialization

<XmlRoot("TABLE")>
Public Class HTMLTable

    <XmlArray("")>
    <XmlArrayItem(GetType(HTMLTableRow), elementName:="TR")>
    Public Property Rows As New List(Of HTMLTableRow)

    <XmlType("TR")>
    Public Class HTMLTableRow

        <XmlArray("TD")>
        Public Property Cells As New List(Of HTMLTableCell)
    End Class

    <XmlType("TD")>
    Public Class HTMLTableCell

        <XmlText()>
        Public Property Value As String
    End Class
   End Class

With a test like:

  <Test()>
    Public Sub SerializeTest()
        Dim tbl As New HTMLTable
        Dim row As New HTMLTable.HTMLTableRow
        Dim cell As New HTMLTable.HTMLTableCell
        row.Cells.Add(cell)
        tbl.Rows.Add(row)
        Debug.Print(XMLProcessor.Serialize(tbl))
    End Sub

I just can’t get it to serialize to this thing. I tried to generate the class using xsd but that produced a lot of garbage code and I really would like to maintain this by hand as it is easier than the monstrosity that xsd produced which didn’t work anyway. What am I doing wrong above?

  • 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-05-28T13:57:54+00:00Added an answer on May 28, 2026 at 1:57 pm

    Try changing:

    <XmlArray("")>
    <XmlArrayItem(GetType(HTMLTableRow), elementName:="TR")>
    Public Property Rows As New List(Of HTMLTableRow)
    

    into:

    <XmlElement("TR")>
    Public Property Rows As New List(Of HTMLTableRow)
    

    , and change:

    <XmlArray("TD")>
    Public Property Cells As New List(Of HTMLTableCell)
    

    into:

    <XmlElement("TD")>
    Public Property Cells As New List(Of HTMLTableCell)
    

    That is how I would set up the attributes when using XmlSerializer for the same task.

    I would also move the HTMLTableRow and HTMLTableCell classes out of the HTMLTable class.

    On another note, your test method isn’t really a test method, since it doesn’t do any Assert and it doesn’t throw an exception when the result doesn’t meet your requirements!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple class that I'm trying to serialize: [ProtoContract] public class
What I'm trying to do is, make the class message serialize and deserialize it's
I have a class that is able to serialize and deserialize with ease after
I'm trying to write a class in Delphi 2007 that uses a ActiveX library.
I'm trying to write a small class library for a C++ course. I was
I am trying to write a Java class to extract a large zip file
I'm trying to write a generic class which contains a generic TObjectList< T >
I was trying to write up a class in c++, and I came across
I'm trying to write a Date class in an attempt to learn C++. I'm
I am trying to write a container class which uses STL allocators. What I

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.