I need to change the xml root tag name from "string" to "TramaOutput". How to achieve this
public string ToXml()
{
XElement element = new XElement("TramaOutput",
new XElement("Artist", "bla"),
new XElement("Title", "Foo"));
return Convert.ToString(element);
}
For this the output is:
<string>
<TramaOutput>
<Artist>bla</Artist>
<Title>Foo</Title>
</TramaOutput>
</string>
In the below mentioned code I am getting an error like "Cannot use wildcards at the top level of a schema."
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Xml.Linq;
namespace WebApplication1
{
/// <summary>
/// Summary description for WebService1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class WebService1 : System.Web.Services.WebService
{
[WebMethod]
public XElement getXl()
{
XElement element = new XElement("Root",new XElement("BookId",1),new XElement("BookId",2));
return element;
}
}
}