本文整理汇总了C#中System.Xml.XmlTextWriter.WriteCData方法的典型用法代码示例。如果您正苦于以下问题:C# XmlTextWriter.WriteCData方法的具体用法?C# XmlTextWriter.WriteCData怎么用?C# XmlTextWriter.WriteCData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlTextWriter
的用法示例。
在下文中一共展示了XmlTextWriter.WriteCData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
protected void Page_Load(object sender, System.EventArgs e)
{
Response.ContentType = "text/xml";
Response.ContentEncoding = Encoding.UTF8;
string mediaType = Request.QueryString["type"];
string mediaID = Request.QueryString["id"];
string wa = "waStartStream";
TextWriter tw = new StreamWriter(Response.OutputStream, Encoding.UTF8);
XmlWriter xw = new XmlTextWriter(tw);
//start doc
xw.WriteStartDocument();
//start root
xw.WriteStartElement("root");
//go
xw.WriteStartElement("go");
xw.WriteAttributeString("to", wa);
xw.WriteEndElement();
//end go
//start title
xw.WriteStartElement("title");
xw.WriteAttributeString("set", wa);
xw.WriteEndElement();
//end title
//start dest
xw.WriteStartElement("destination");
xw.WriteAttributeString("mode", "replace");
xw.WriteAttributeString("zone", wa);
xw.WriteAttributeString("create", "true");
xw.WriteEndElement();
//end dest
//start data
xw.WriteStartElement("data");
xw.WriteCData(DoCountdown(mediaID, mediaType));
xw.WriteEndElement();
//end data
//start script
xw.WriteStartElement("script");
xw.WriteCData("startCountdown(21)");
xw.WriteEndElement();
//end script
//end root
xw.WriteEndElement();
//end doc
xw.WriteEndDocument();
xw.Close();
}
示例2: WriteXmlElement
private void WriteXmlElement(TraceRecord rec)
{
using (Stream xmlFile = new FileStream(@"D:\Ari Gunawan\Belajar\WEB API\Code\Apress.PracticalWebApi.HelloWebApi\log.xml", FileMode.Append))
{
using (XmlTextWriter writer = new XmlTextWriter(xmlFile, Encoding.UTF8))
{
writer.Formatting = Formatting.Indented;
writer.WriteStartElement("trace");
writer.WriteElementString("timestamp", rec.Timestamp.ToString());
writer.WriteElementString("operation", rec.Operation);
writer.WriteElementString("user", rec.Operator);
if (!String.IsNullOrWhiteSpace(rec.Message))
{
writer.WriteStartElement("message");
writer.WriteCData(rec.Message);
writer.WriteEndElement();
}
writer.WriteElementString("category", rec.Category);
writer.WriteEndElement();
writer.WriteString(Environment.NewLine);
writer.Flush();
}
}
}
示例3: AddRssItem
/// <summary>
/// Adds a single item to the XmlTextWriter supplied
/// </summary>
/// <param name="writer">The XmlTextWriter to be written to</param>
/// <param name="sItemTitle">The title of the RSS item</param>
/// <param name="sItemLink">The URL of the RSS item</param>
/// <param name="sItemDescription">The RSS item text itself</param>
/// <param name="sPubDate"></param>
/// <param name="bDescAsCdata">Write description as CDATA</param>
/// <returns>The XmlTextWriter with the item info written to it</returns>
public XmlTextWriter AddRssItem(XmlTextWriter writer, string sItemTitle, string sItemLink, string sItemDescription, DateTime sPubDate, bool bDescAsCdata)
{
writer.WriteStartElement("item");
writer.WriteElementString("title", sItemTitle);
writer.WriteElementString("link", sItemLink);
if (bDescAsCdata)
{
// Now we can write the description as CDATA to support html content.
// We find this used quite often in aggregators
writer.WriteStartElement("description");
writer.WriteCData(sItemDescription);
writer.WriteEndElement();
}
else
{
writer.WriteElementString("description", sItemDescription);
}
writer.WriteElementString("pubDate", sPubDate.ToString("r"));
writer.WriteEndElement();
return writer;
}
示例4: Page_Load
protected void Page_Load(object sender, System.EventArgs e)
{
Response.ContentType = "text/xml";
Response.ContentEncoding = Encoding.UTF8;
string wa = "waSettingsResult";
string pagesize = Request.QueryString["pagesize"];
string order = Request.QueryString["order"];
string client = Request.QueryString["client"];
string server = Request.QueryString["server"];
string submenu = Request.QueryString["submenu"];
string recsubmenu = Request.QueryString["recsubmenu"];
string recent = Request.QueryString["recent"];
string myvideos = Request.QueryString["myvideos"];
string sortlists = Request.QueryString["sortlists"];
string guidedays = Request.QueryString["guidedays"];
TextWriter tw = new StreamWriter(Response.OutputStream, Encoding.UTF8);
XmlWriter xw = new XmlTextWriter(tw);
//start doc
xw.WriteStartDocument();
//start root
xw.WriteStartElement("root");
//go
xw.WriteStartElement("go");
xw.WriteAttributeString("to", wa);
xw.WriteEndElement();
//end go
//start title
xw.WriteStartElement("title");
xw.WriteAttributeString("set", wa);
xw.WriteEndElement();
//end title
//start dest
xw.WriteStartElement("destination");
xw.WriteAttributeString("mode", "replace");
xw.WriteAttributeString("zone", wa);
xw.WriteAttributeString("create", "true");
xw.WriteEndElement();
//end dest
//start data
xw.WriteStartElement("data");
xw.WriteCData(UpdateSettings(pagesize, order, server, client, submenu, recsubmenu, recent, myvideos, sortlists, guidedays));
xw.WriteEndElement();
//end data
//end root
xw.WriteEndElement();
//end doc
xw.WriteEndDocument();
xw.Close();
}
示例5: Page_Load
protected void Page_Load(object sender, System.EventArgs e)
{
Response.ContentType = "text/xml";
Response.ContentEncoding = Encoding.UTF8;
string path = Request.QueryString["path"];
string start = Request.QueryString["start"];
string wa = "waRecDelete";
TextWriter tw = new StreamWriter(Response.OutputStream, Encoding.UTF8);
XmlWriter xw = new XmlTextWriter(tw);
//start doc
xw.WriteStartDocument();
//start root
xw.WriteStartElement("root");
//go
xw.WriteStartElement("go");
xw.WriteAttributeString("to", wa);
xw.WriteEndElement();
//end go
//start title
xw.WriteStartElement("title");
xw.WriteAttributeString("set", wa);
xw.WriteEndElement();
//end title
//start dest
xw.WriteStartElement("destination");
if (Convert.ToInt32(start) == 0)
{
xw.WriteAttributeString("mode", "replace");
xw.WriteAttributeString("zone", wa);
xw.WriteAttributeString("create", "true");
}
else
{
xw.WriteAttributeString("mode", "self");
xw.WriteAttributeString("zone", "moredrive");
}
xw.WriteEndElement();
//end dest
//start data
xw.WriteStartElement("data");
xw.WriteCData(DisplayRecordingsDeleteMenu(wa, Convert.ToInt32(start), path));
xw.WriteEndElement();
//end data
//end root
xw.WriteEndElement();
//end doc
xw.WriteEndDocument();
xw.Close();
}
示例6: Page_Load
protected void Page_Load(object sender, System.EventArgs e)
{
Response.ContentType = "text/xml";
Response.ContentEncoding = Encoding.UTF8;
string wa = "waCreateUser";
string newpass = Request.QueryString["newpass"];
string confpass = Request.QueryString["confpass"];
string username = Request.QueryString["user"];
bool recorder = Convert.ToBoolean(Request.QueryString["recorder"]);
bool watcher = Convert.ToBoolean(Request.QueryString["watcher"]);
bool deleter = Convert.ToBoolean(Request.QueryString["deleter"]);
bool remoter = Convert.ToBoolean(Request.QueryString["remoter"]);
bool admin = Convert.ToBoolean(Request.QueryString["admin"]);
TextWriter tw = new StreamWriter(Response.OutputStream, Encoding.UTF8);
XmlWriter xw = new XmlTextWriter(tw);
//start doc
xw.WriteStartDocument();
//start root
xw.WriteStartElement("root");
//go
xw.WriteStartElement("go");
xw.WriteAttributeString("to", wa);
xw.WriteEndElement();
//end go
//start title
xw.WriteStartElement("title");
xw.WriteAttributeString("set", wa);
xw.WriteEndElement();
//end title
//start dest
xw.WriteStartElement("destination");
xw.WriteAttributeString("mode", "replace");
xw.WriteAttributeString("zone", wa);
xw.WriteAttributeString("create", "true");
xw.WriteEndElement();
//end dest
//start data
xw.WriteStartElement("data");
xw.WriteCData(CreateUser(username, newpass, confpass, recorder, watcher, deleter, remoter, admin, wa));
xw.WriteEndElement();
//end data
//end root
xw.WriteEndElement();
//end doc
xw.WriteEndDocument();
xw.Close();
}
示例7: Page_Load
protected void Page_Load(object sender, System.EventArgs e)
{
Response.ContentType = "text/xml";
Response.ContentEncoding = Encoding.UTF8;
string wa = "waClientUpdateResult";
uWiMP.TVServer.MPClient.Client client = new uWiMP.TVServer.MPClient.Client();
client.Friendly = Request.QueryString["friendly"];
client.Hostname = Request.QueryString["hostname"];
client.Port = Request.QueryString["port"];
client.MACAddress = Request.QueryString["macaddress"];
client.usesMovingPictures = Convert.ToBoolean(Request.QueryString["usemovpics"]);
client.usesTVSeries = Convert.ToBoolean(Request.QueryString["usetvseries"]);
TextWriter tw = new StreamWriter(Response.OutputStream, Encoding.UTF8);
XmlWriter xw = new XmlTextWriter(tw);
//start doc
xw.WriteStartDocument();
//start root
xw.WriteStartElement("root");
//go
xw.WriteStartElement("go");
xw.WriteAttributeString("to", wa);
xw.WriteEndElement();
//end go
//start title
xw.WriteStartElement("title");
xw.WriteAttributeString("set", wa);
xw.WriteEndElement();
//end title
//start dest
xw.WriteStartElement("destination");
xw.WriteAttributeString("mode", "replace");
xw.WriteAttributeString("zone", wa);
xw.WriteAttributeString("create", "true");
xw.WriteEndElement();
//end dest
//start data
xw.WriteStartElement("data");
xw.WriteCData(UpdateClient(wa, client));
xw.WriteEndElement();
//end data
//end root
xw.WriteEndElement();
//end doc
xw.WriteEndDocument();
xw.Close();
}
示例8: Write
public void Write(IFileSystem fs, ContentItem item, XmlTextWriter writer)
{
writer.WriteStartElement("fake");
string x = item[Name] as string;
writer.WriteAttributeString("blah", x);
writer.WriteCData(x.ToUpper());
writer.WriteEndElement();
item["wasWritten"] = true;
}
示例9: Page_Load
protected void Page_Load(object sender, System.EventArgs e)
{
Response.ContentType = "text/xml";
Response.ContentEncoding = Encoding.UTF8;
string friendly = Request.QueryString["friendly"];
string album = Request.QueryString["album"];
string artist = Request.QueryString["artist"];
string shuffle = (bool)Request.QueryString["shuffle"];
string enqueue = (bool)Request.QueryString["enqueue"];
string tracks = Replace(Request.QueryString["tracks"], " ", ",");
string wa = "waMPClientPlayMusic";
TextWriter tw = new StreamWriter(Response.OutputStream, Encoding.UTF8);
XmlWriter xw = new XmlTextWriter(tw);
//start doc
xw.WriteStartDocument();
//start root
xw.WriteStartElement("root");
//go
xw.WriteStartElement("go");
xw.WriteAttributeString("to", wa);
xw.WriteEndElement();
//end go
//start title
xw.WriteStartElement("title");
xw.WriteAttributeString("set", wa);
xw.WriteEndElement();
//end title
//start dest
xw.WriteStartElement("destination");
xw.WriteAttributeString("mode", "replace");
xw.WriteAttributeString("zone", wa);
xw.WriteAttributeString("create", "true");
xw.WriteEndElement();
//end dest
//start data
xw.WriteStartElement("data");
xw.WriteCData(PlayMusic(friendly, album, artist, shuffle, enqueue, tracks));
xw.WriteEndElement();
//end data
//end root
xw.WriteEndElement();
//end doc
xw.WriteEndDocument();
xw.Close();
}
示例10: Page_Load
protected void Page_Load(object sender, System.EventArgs e)
{
Response.ContentType = "text/xml";
Response.ContentEncoding = Encoding.UTF8;
string groupID = Request.QueryString["group"];
string wa = "waRadioSearchResults" + groupID;
string search = Request.QueryString["search"];
string genre = Request.QueryString["genre"];
bool desc = Convert.ToBoolean(Request.QueryString["desc"]);
if (genre == "")
genre = "all";
TextWriter tw = new StreamWriter(Response.OutputStream, Encoding.UTF8);
XmlWriter xw = new XmlTextWriter(tw);
//start doc
xw.WriteStartDocument();
//start root
xw.WriteStartElement("root");
//go
xw.WriteStartElement("go");
xw.WriteAttributeString("to", wa);
xw.WriteEndElement();
//end go
//start title
xw.WriteStartElement("title");
xw.WriteAttributeString("set", wa);
xw.WriteEndElement();
//end title
//start dest
xw.WriteStartElement("destination");
xw.WriteAttributeString("mode", "replace");
xw.WriteAttributeString("zone", wa);
xw.WriteAttributeString("create", "true");
xw.WriteEndElement();
//end dest
//start data
xw.WriteStartElement("data");
xw.WriteCData(DisplaySearchResults(groupID, genre, search, desc));
xw.WriteEndElement();
//end data
//end root
xw.WriteEndElement();
//end doc
xw.WriteEndDocument();
xw.Close();
}
示例11: GetOutput
public void GetOutput(System.IO.Stream outputStream, List<Common.Model.ChargePoint> dataList, Common.APIRequestParams settings)
{
/*<Document>
<Placemark>
<name>Sacramento County Parking Garage</name>
<description>1 SP Inductive 1 Avcon Conductive</description>
<Point>
<coordinates>-121.49610000,38.58460000</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Sacramento City Public Parking Garage</name>
<description>3 SP Inductive</description>
<Point>
<coordinates>-121.49382900,38.57830300</coordinates>
</Point>
</Placemark>
</Document>
* */
XmlTextWriter xml = new XmlTextWriter(outputStream, Encoding.UTF8);
//start xml document
xml.WriteStartDocument();
if (this.SelectedKMLVersion== KMLVersion.V2) xml.WriteStartElement("kml", "http://www.opengis.net/kml/2.2");
xml.WriteStartElement("Document");
xml.WriteElementString("name","Open Charge Map - Electric Vehicle Charging Locations");
xml.WriteElementString("description", "Data from http://openchargemap.org/");
foreach (var item in dataList)
{
if (item.AddressInfo != null)
{
xml.WriteStartElement("Placemark");
xml.WriteAttributeString("id", "OCM-"+item.ID.ToString());
xml.WriteElementString("name", item.AddressInfo.Title);
//remove invalid character ranges before serializing to XML
var description = Regex.Replace(item.GetSummaryDescription(true), @"[^\u0009\u000a\u000d\u0020-\uD7FF\uE000-\uFFFD]", string.Empty);
xml.WriteStartElement("description");
xml.WriteCData(description);
xml.WriteEndElement();
xml.WriteStartElement("Point");
string coords = item.AddressInfo.Longitude.ToString() + "," + item.AddressInfo.Latitude.ToString();
xml.WriteElementString("coordinates", coords);
xml.WriteEndElement();
xml.WriteEndElement();
}
}
xml.WriteEndElement();
if (this.SelectedKMLVersion == KMLVersion.V2) xml.WriteEndElement(); //</kml>
xml.WriteEndDocument();
xml.Flush();
//xml.Close();
}
示例12: Page_Load
protected void Page_Load(object sender, System.EventArgs e)
{
Response.ContentType = "text/xml";
Response.ContentEncoding = Encoding.UTF8;
string wa = "waRadioRecordManualConfirm";
int channelID = Convert.ToInt32(Request.QueryString["channel"]);
string schedName = Request.QueryString["schedName"];
string startDate = Request.QueryString["startdate"];
string startTime = Request.QueryString["starttime"];
string duration = Request.QueryString["duration"];
TextWriter tw = new StreamWriter(Response.OutputStream, Encoding.UTF8);
XmlWriter xw = new XmlTextWriter(tw);
//start doc
xw.WriteStartDocument();
//start root
xw.WriteStartElement("root");
//go
xw.WriteStartElement("go");
xw.WriteAttributeString("to", wa);
xw.WriteEndElement();
//end go
//start title
xw.WriteStartElement("title");
xw.WriteAttributeString("set", wa);
xw.WriteEndElement();
//end title
//start dest
xw.WriteStartElement("destination");
xw.WriteAttributeString("mode", "replace");
xw.WriteAttributeString("zone", wa);
xw.WriteAttributeString("create", "true");
xw.WriteEndElement();
//end dest
//start data
xw.WriteStartElement("data");
xw.WriteCData(RecordProgram(channelID, schedName, startDate, startTime, duration));
xw.WriteEndElement();
//end data
//end root
xw.WriteEndElement();
//end doc
xw.WriteEndDocument();
xw.Close();
}
示例13: Page_Load
protected void Page_Load(object sender, System.EventArgs e)
{
Response.ContentType = "text/xml";
Response.ContentEncoding = Encoding.UTF8;
string oldpass = Request.QueryString["oldpass"];
string newpass = Request.QueryString["newpass"];
string confpass = Request.QueryString["confpass"];
string wa = "waChangePass";
TextWriter tw = new StreamWriter(Response.OutputStream, Encoding.UTF8);
XmlWriter xw = new XmlTextWriter(tw);
//start doc
xw.WriteStartDocument();
//start root
xw.WriteStartElement("root");
//go
xw.WriteStartElement("go");
xw.WriteAttributeString("to", wa);
xw.WriteEndElement();
//end go
//start title
xw.WriteStartElement("title");
xw.WriteAttributeString("set", wa);
xw.WriteEndElement();
//end title
//start dest
xw.WriteStartElement("destination");
xw.WriteAttributeString("mode", "replace");
xw.WriteAttributeString("zone", wa);
xw.WriteAttributeString("create", "true");
xw.WriteEndElement();
//end dest
//start data
xw.WriteStartElement("data");
xw.WriteCData(ChangePassword(oldpass, newpass, confpass, wa));
xw.WriteEndElement();
//end data
//end root
xw.WriteEndElement();
//end doc
xw.WriteEndDocument();
xw.Close();
}
示例14: Page_Load
protected void Page_Load(object sender, System.EventArgs e)
{
Response.ContentType = "text/xml";
Response.ContentEncoding = Encoding.UTF8;
string friendly = Request.QueryString["friendly"];
string filter = Request.QueryString["filter"];
string value = Request.QueryString["value"];
string wa = "waMPClientPlayRandom";
TextWriter tw = new StreamWriter(Response.OutputStream, Encoding.UTF8);
XmlWriter xw = new XmlTextWriter(tw);
//start doc
xw.WriteStartDocument();
//start root
xw.WriteStartElement("root");
//go
xw.WriteStartElement("go");
xw.WriteAttributeString("to", wa);
xw.WriteEndElement();
//end go
//start title
xw.WriteStartElement("title");
xw.WriteAttributeString("set", wa);
xw.WriteEndElement();
//end title
//start dest
xw.WriteStartElement("destination");
xw.WriteAttributeString("mode", "replace");
xw.WriteAttributeString("zone", wa);
xw.WriteAttributeString("create", "true");
xw.WriteEndElement();
//end dest
//start data
xw.WriteStartElement("data");
xw.WriteCData(PlayRandom(friendly, filter, value));
xw.WriteEndElement();
//end data
//end root
xw.WriteEndElement();
//end doc
xw.WriteEndDocument();
xw.Close();
}
示例15: Page_Load
protected void Page_Load(object sender, System.EventArgs e)
{
Response.ContentType = "text/xml";
Response.ContentEncoding = Encoding.UTF8;
string wa = "waMyMusicListAlbum";
string friendly = Request.QueryString["friendly"];
string album = Server.UrlDecode(Request.QueryString["album"]);
string artist = Server.UrlDecode(Request.QueryString["artist"]);
TextWriter tw = new StreamWriter(Response.OutputStream, Encoding.UTF8);
XmlWriter xw = new XmlTextWriter(tw);
//start doc
xw.WriteStartDocument();
//start root
xw.WriteStartElement("root");
//go
xw.WriteStartElement("go");
xw.WriteAttributeString("to", wa);
xw.WriteEndElement();
//end go
//start title
xw.WriteStartElement("title");
xw.WriteAttributeString("set", wa);
xw.WriteEndElement();
//end title
//start dest
xw.WriteStartElement("destination");
xw.WriteAttributeString("mode", "replace");
xw.WriteAttributeString("zone", wa);
xw.WriteAttributeString("create", "true");
xw.WriteEndElement();
//end dest
//start data
xw.WriteStartElement("data");
xw.WriteCData(DisplayAlbum(wa, friendly, album, artist));
xw.WriteEndElement();
//end data
//end root
xw.WriteEndElement();
//end doc
xw.WriteEndDocument();
xw.Close();
}