Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have an xml. I want create class for this xml, but visual studio xml to class generator give not correct code.
XML
<root>
   <tag atr1="value">
   <tag atr2="value">
   <tag3>value


C#
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
public partial class root
{

    private rootTag[] tagField;

    private string tag3Field;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("tag")]
    public rootTag[] tag
    {
        get
        {
            return this.tagField;
        }
        set
        {
            this.tagField = value;
        }
    }

    /// <remarks/>
    public string tag3
    {
        get
        {
            return this.tag3Field;
        }
        set
        {
            this.tag3Field = value;
        }
    }
}

/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
public partial class rootTag
{

    private string atr1Field;

    private string atr2Field;

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string atr1
    {
        get
        {
            return this.atr1Field;
        }
        set
        {
            this.atr1Field = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string atr2
    {
        get
        {
            return this.atr2Field;
        }
        set
        {
            this.atr2Field = value;
        }
    }
}


What I have tried:

i try use vs xml to class generator.
Posted
Updated 7-Dec-16 8:08am
v2
Comments
Wastedtalent 19-Dec-16 6:39am    
Why is the code incorrect?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900