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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:13:47+00:00 2026-05-27T08:13:47+00:00

I auto-generated some classes using xsd.exe for a project I am working on. I

  • 0
  1. I auto-generated some classes using xsd.exe for a project I am working on.
  2. I am building an xml document using the auto-generated classes.
  3. A subset of the schema is very html-like and I am trying to bring raw HTML into my classes
  4. To that end, I’m trying to deserialize an HTML snippet into the class (not the root node) that corresponds to HTML in my document.

It sounds good in theory right? The problem is that my raw text wont deserialize. Am I doing something wrong? I have a lot of experience with XML and basic experience with the .NET XmlSerializer. The serializer doesn’t error, it just fails to deserialize the contents.

This is the code I am using to deserialize:

    Dim FromValue As String = "<StrucDoc.Text><table><tr><td>Inside Text</td></tr></table></StrucDoc.Text>"
    Dim ms As New IO.MemoryStream(Encoding.UTF8.GetBytes(FromValue))
    Dim ToValue As HL7.V3.StrucDocText
    Dim t As New System.Xml.Serialization.XmlSerializer(GetType(HL7.V3.StrucDocText))
    ToValue = t.Deserialize(ms)

The is the important part of the auto-generated code… It’s very large:

'''<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1"), _
 System.SerializableAttribute(), _
 System.Diagnostics.DebuggerStepThroughAttribute(), _
 System.ComponentModel.DesignerCategoryAttribute("code"), _
 System.Xml.Serialization.XmlTypeAttribute(TypeName:="StrucDoc.Text", [Namespace]:="urn:hl7-org:v3")> _
Partial Public Class StrucDocText

Private itemsField() As Object

Private textField() As String

Private idField As String

Private languageField As String

Private styleCodeField As String

Private mediaTypeField As String

Public Sub New()
    MyBase.New()
    Me.mediaTypeField = "text/x-hl7-text+xml"
End Sub

'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute("br", GetType(StrucDocBr)), _
 System.Xml.Serialization.XmlElementAttribute("content", GetType(StrucDocContent)), _
 System.Xml.Serialization.XmlElementAttribute("footnote", GetType(StrucDocFootnote)), _
 System.Xml.Serialization.XmlElementAttribute("footnoteRef", GetType(StrucDocFootnoteRef)), _
 System.Xml.Serialization.XmlElementAttribute("linkHtml", GetType(StrucDocLinkHtml)), _
 System.Xml.Serialization.XmlElementAttribute("list", GetType(StrucDocList)), _
 System.Xml.Serialization.XmlElementAttribute("paragraph", GetType(StrucDocParagraph)), _
 System.Xml.Serialization.XmlElementAttribute("renderMultiMedia", GetType(StrucDocRenderMultiMedia)), _
 System.Xml.Serialization.XmlElementAttribute("sub", GetType(StrucDocSub)), _
 System.Xml.Serialization.XmlElementAttribute("sup", GetType(StrucDocSup)), _
 System.Xml.Serialization.XmlElementAttribute("table", GetType(StrucDocTable))> _
Public Property Items() As Object()
    Get
        Return Me.itemsField
    End Get
    Set(ByVal value As Object())
        Me.itemsField = value
    End Set
End Property

'''<remarks/>
<System.Xml.Serialization.XmlTextAttribute()> _
Public Property Text() As String()
    Get
        Return Me.textField
    End Get
    Set(ByVal value As String())
        Me.textField = value
    End Set
End Property

'''<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute(DataType:="ID")> _
Public Property ID() As String
    Get
        Return Me.idField
    End Get
    Set(ByVal value As String)
        Me.idField = value
    End Set
End Property

'''<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute(DataType:="NMTOKEN")> _
Public Property language() As String
    Get
        Return Me.languageField
    End Get
    Set(ByVal value As String)
        Me.languageField = value
    End Set
End Property

'''<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute(DataType:="NMTOKENS")> _
Public Property styleCode() As String
    Get
        Return Me.styleCodeField
    End Get
    Set(ByVal value As String)
        Me.styleCodeField = value
    End Set
End Property

'''<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute()> _
Public Property mediaType() As String
    Get
        Return Me.mediaTypeField
    End Get
    Set(ByVal value As String)
        Me.mediaTypeField = value
    End Set
End Property
End Class

After execution, the ToValue.itemsField == null. I am expecting an array with one StrucDocTable element.

Any help would be appreciated.

  • 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-27T08:13:47+00:00Added an answer on May 27, 2026 at 8:13 am

    Found the answer and I am sharing it for the sanity of all. I had two problems:

    1. The html just be exactly formatted in the desired structure. I added tbody to the HTML.
    2. Added XML namespacing to the markup and the XmlSerializer construction.

      Dim FromValue As String = "<StrucDoc.Text xmlns=""urn:hl7-org:v3""><table><tbody><tr><td>Inside Text</td></tr></tbody></table></StrucDoc.Text>"
      Dim ms As New IO.MemoryStream(Encoding.UTF8.GetBytes(FromValue))
      Dim ToValue As HL7.V3.StrucDocText
      Dim t As New System.Xml.Serialization.XmlSerializer(GetType(HL7.V3.StrucDocText), "urn:hl7-org:v3")
      ToValue = t.Deserialize(ms)
      

    After this, I get my values exactly as expected! I hope this helps someone out there!

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

Sidebar

Related Questions

I'm working on databases that have moving tables auto-generated by some obscure tools. By
I have a maven library project with some classes to deal xml messages. Whenever
I am using the .xsd dataset thingies (which I hate) to auto-generate TableAdapter classes
I have a constructor (for an auto generated class) that has 255 paremeters. Using
I'm trying to debug some auto-generated code, but I am a mySQL noob. Everything
I have an applicaton that contains some tables that are auto-generated from Grails domain
I'm using DataAnnotations for validation of a custom class (LINQ to SQL auto generated)
Using MVC 3 @html.EditorForModel , the auto-generated template spits out <div class=editor-label>.... <div class=editor-field>....
I have some ASP.NET (MVC2) auto generated html which is creating forms looking like
I have a web page with some auto-generated javascript content which manipulates the DOM

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.