private void saveCourseXML() { string dir = System.Web.HttpContext.Current.Server.MapPath("..\\") + "\\Courses\\"; try { //Check to see if folder and file exist if (Directory.Exists(dir)) { // Use the CourseID to create a unique xml filename for the course. string filename = this.CourseID + ".xml"; //Create CourseID.xml file System.Xml.XmlTextWriter xmlwriter = new System.Xml.XmlTextWriter(dir + filename, null); xmlwriter.Formatting = System.Xml.Formatting.Indented; xmlwriter.WriteStartDocument(false); // xmlwriter.WriteDocType("Course", null, null, null); xmlwriter.WriteStartElement("course"); xmlwriter.WriteStartElement("name"); if (this.Name != null && this.Name != "") { xmlwriter.WriteCData(this.Name); } xmlwriter.WriteEndElement(); xmlwriter.WriteStartElement("assnmgr"); xmlwriter.WriteStartElement("amurl"); if (SharedSupport.UsingSsl == true) { xmlwriter.WriteCData(@"https://" + SharedSupport.BaseUrl); } else { xmlwriter.WriteCData(@"http://" + SharedSupport.BaseUrl); } xmlwriter.WriteEndElement(); xmlwriter.WriteStartElement("guid"); xmlwriter.WriteCData(this._courseGUID.ToString()); xmlwriter.WriteEndElement(); xmlwriter.WriteEndElement(); xmlwriter.WriteEndElement(); //write the xml to the file and close xmlwriter.Flush(); xmlwriter.Close(); } else { throw new Exception(SharedSupport.GetLocalizedString("Course_DirectoryDoesNotExist")); //"Directory could not be found. " + dir); } } catch (System.Exception ex) { SharedSupport.HandleError(ex); } }
protected void Page_Load(object sender, EventArgs e) { Response.ContentEncoding = System.Text.Encoding.UTF8; Response.ContentType = "text/xml"; Response.Cache.SetCacheability(HttpCacheability.NoCache); int callstack_uid; if (int.TryParse(Request.QueryString["callstack_uid"], out callstack_uid) == false) { callstack_uid = 1; } using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8)) { writer.WriteStartDocument(); writer.WriteStartElement("Callstack"); string callstack; if (DB.LoadCallstackPreview(callstack_uid, out callstack)) { writer.WriteCData(callstack); } writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); writer.Close(); } }
public string ToXml() { StringWriter xmlStream = null; System.Xml.XmlTextWriter xmlWriter = null; try { xmlStream = new StringWriter(); xmlWriter = new System.Xml.XmlTextWriter(xmlStream); // Start Document Element xmlWriter.WriteStartElement("ServiceParameters"); if (this.PublicKey != null) { xmlWriter.WriteStartElement("Item"); xmlWriter.WriteAttributeString("key", "PublicKey"); xmlWriter.WriteString(this.PublicKey); xmlWriter.WriteEndElement(); } Enumerator enumerator = this.GetEnumerator(); try { while (enumerator.MoveNext()) { xmlWriter.WriteStartElement("Item"); xmlWriter.WriteAttributeString("key", enumerator.Current.Key); xmlWriter.WriteCData(enumerator.Current.Value); xmlWriter.WriteEndElement(); } } finally { enumerator.Dispose(); } // End Document Element xmlWriter.WriteEndElement(); xmlWriter.Flush(); return(xmlStream.ToString()); } catch (Exception) { return(string.Empty); } finally { xmlWriter?.Close(); xmlStream?.Close(); } }
protected override void WriteStart(System.Xml.XmlTextWriter wr) { base.WriteStart(wr); wr.WriteStartElement("stack"); try { wr.WriteCData(Environment.StackTrace); } finally { wr.WriteEndElement(); //stack } }
protected void Page_Load(object sender, EventArgs e) { Response.ContentEncoding = System.Text.Encoding.UTF8; Response.ContentType = "text/xml"; Response.Cache.SetCacheability(HttpCacheability.NoCache); int callstack_uid; if (int.TryParse(Request.QueryString["callstack_uid"], out callstack_uid) == false) { callstack_uid = 1; } using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8)) { writer.WriteStartDocument(); writer.WriteStartElement("Comment"); writer.WriteAttributeString("callstack_uid", callstack_uid.ToString()); DB.ForEachCallstackComment CommentWriter = delegate(string author, string comment, DateTime created) { writer.WriteStartElement("Item"); writer.WriteAttributeString("author", author); writer.WriteAttributeString("created", created.ToString()); writer.WriteCData(comment); writer.WriteEndElement(); }; DB.LoadCallstackComment(callstack_uid, CommentWriter); writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); writer.Close(); } }
public void WriteXmlTo(System.Xml.XmlTextWriter xml) { xml.WriteStartElement("workUnit"); xml.WriteAttributeString("lat", lat.ToString()); xml.WriteAttributeString("lng", lng.ToString()); xml.WriteAttributeString("workCapacity", workCapacity.ToString()); xml.WriteAttributeString("realm3", tenylegesKobmeter.ToString()); xml.WriteAttributeString("period", napszak.ToString()); xml.WriteAttributeString("id", number.ToString()); xml.WriteAttributeString("street", utca); xml.WriteAttributeString("house", hazSzam); xml.WriteAttributeString("zip", irSzam.ToString()); xml.WriteAttributeString("pipe", csoHossz.ToString()); xml.WriteAttributeString("sheetNo", worksheetNumber.ToString()); xml.WriteAttributeString("prob", problematic.ToString()); xml.WriteAttributeString("foldlat", foldLat.ToString()); xml.WriteAttributeString("foldlng", foldLng.ToString()); xml.WriteAttributeString("foldhossz", foldHossz.ToString()); xml.WriteCData(megjegyzes); xml.WriteEndElement(); }
protected void Page_Load(object sender, EventArgs e) { Response.ContentEncoding = System.Text.Encoding.UTF8; Response.ContentType = "text/xml"; Response.Cache.SetCacheability(HttpCacheability.NoCache); int callstack_uid; if (int.TryParse(Request.QueryString["callstack_uid"], out callstack_uid) == false) callstack_uid = 1; using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8)) { writer.WriteStartDocument(); writer.WriteStartElement("Comment"); writer.WriteAttributeString("callstack_uid", callstack_uid.ToString()); DB.ForEachCallstackComment CommentWriter = delegate(string author, string comment, DateTime created) { writer.WriteStartElement("Item"); writer.WriteAttributeString("author", author); writer.WriteAttributeString("created", created.ToString()); writer.WriteCData(comment); writer.WriteEndElement(); }; DB.LoadCallstackComment(callstack_uid, CommentWriter); writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); writer.Close(); } }
private void WriteCData(System.Xml.XmlTextWriter writer, string tag, string value) { writer.WriteStartElement(tag); writer.WriteCData(value); writer.WriteEndElement(); }
private void GlobalSaving(Crownwood.Magic.Controls.TabbedGroups tg, System.Xml.XmlTextWriter xmlOut) { // Persist the global text box contents xmlOut.WriteCData(_global.Text); }