XML Attributes

So far, we've seen how to return intrinsic types and UDTs from a WebService. The basic serialization provided by WebServices will generally suffice, but there are times when it is necessary to control the representation of elements being returned.

An XML document can have at most one root. An XML root can be defined by making use of the XMLRootAttribute. The XMLRootAttribute is used to specify the following properties in Table 4.4.1.

Table 4.4.1. XMLRootAttribute Instance Properties
Property Meaning
DataType XML data type of the root element
ElementName The name of the root element
Form Qualified or unqualified root element name
IsNullable Determines if the XmlSerializer should serialize if set to null
Namespace Namespace for the ...

Get C# and the .NET Framework: The C++ Perspective now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.