ベタコードブログ -3ページ目

XMLをResponseする。


//<persons>
// <person>
// <name>tamaki</name>
// <age>35</age>
// </person>
//</persons>


XElement root = new XElement("persons");
XElement person = new XElement("person");


XElement name = new XElement("name", "tamaki");
XElement age = new XElement("age", "35");

person.Add(name);
person.Add(age);


root.Add(person);


Response.ContentType = "application/x-www-form-urlencoded";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.Write(root);
Response.End();