1

I have the following class

    [XmlRoot(ElementName= "webSites")] //No capital w at the beginning
public class WebSites : List<WebSite>
{

}

public class WebSite
{
    [XmlAttribute("name")]
    public string Name { set; get; }
    [XmlAttribute("url")]
    public String Url { set; get; }
}

this is serialized to

 <?xml version="1.0" encoding="DOS-862"?>
<webSites xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http:
//www.w3.org/2001/XMLSchema">
  <WebSite name="nice website" url="mydomain.com" />

this is almost ok but I want that WebSite(With a capital) will be webSite (no capital) I know I can specify this only for the root, but how can I for an internal member?

1 Answer 1

3
[XmlType("webSite")]
public class WebSite {...}

or to control a collection property on a wrapper class:

[XmlArrayItem("webSite")]
[XmlArray("sites")]
public WebSites Sites { get; set; }
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I was searching for all the attributes, but didn't realize it was so easy :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.