Results 1 to 4 of 4

Thread: [RESOLVED] XML with Attributes

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2007
    Posts
    544

    Resolved [RESOLVED] XML with Attributes

    Say I have a class

    Class Business
    Name as string
    end Class

    The XML will be

    <Business>
    <Name>Hello World</Name>
    </Business>

    What about if I want that to be

    <Business Name="Hello World" /> instead

    How would I do so?

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: XML with Attributes

    you need to use the XMLAttribute markup on the property....

    Code:
    Imports System.Xml.Serialization
    
    <Serializable()> _
    Public Class Business
    
        Private _name As String
    
        <XmlAttribute()> _
        Public Property Name() As String
            Get
                Return _name
            End Get
            Set(ByVal value As String)
                _name = value
            End Set
        End Property
    
    
    End Class
    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2007
    Posts
    544

    Re: XML with Attributes

    Where can I see more documentation on this?

    Yes I googled and bing the whole thing:

    This

    http://msdn.microsoft.com/en-us/libr...attribute.aspx

    doesn't look like it.

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: XML with Attributes

    yeah, no that's not it.....

    try the OTHER namespace:
    System.Xml.Serialization


    or xml.serialization.xmlattribute ... the one you found was for the xml dom....
    http://msdn.microsoft.com/en-us/libr...attribute.aspx
    Yeah... the search is great, but sometimes you jsut gotta know exactly how to search what you're looking for.

    Hope it helps.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width