It's easy to create the Format using the "fluent" constructors of
XDocument
,
XElement
, ...
You can do it like this:
public static XDocument CreateDocument()
{
return new XDocument(
new XElement("Body",
new XElement("getBooksResponse", new XAttribute("ns", "http://tempuri.org/"),
new XElement("getBooksResult",
new XElement("T", "book2"),
new XElement("A", "author2"),
new XElement("P", "10")
)
)
)
);
}
(If you'd name your attribute xmlns the XML is invalid)
Sorry I don't understand what you mean with Point 1,2...
But I'd suggest to use a class hierarchy representing your data, and use
DataContractSerializer
to produce the XML.