// // METHOD : BuildDetail // DESCRIPTION : Create bulk of error log, parameters fill in the specific details like error type, variable name, and explanation // PARAMETERS : string name - Variable name // string type - Error type // string explanation - Explanation of error // RETURNS : XmlNode node - XML containing constructed log. // public XmlNode BuildDetail(string name, string type, string explanation) { XmlDocument doc = new System.Xml.XmlDocument(); XmlNode node = doc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace); XmlNode details; XmlAttribute nameAttr; XmlAttribute errorTypeAttr; XmlAttribute explanationAttr; details = doc.CreateNode(XmlNodeType.Element, "ParameterError", "http://localhost/LoanService"); nameAttr = doc.CreateAttribute("s", "name", "http://localhost/LoanService"); nameAttr.Value = name; errorTypeAttr = doc.CreateAttribute("s", "errorType", "http://localhost/LoanService"); errorTypeAttr.Value = type; explanationAttr = doc.CreateAttribute("s", "explanation", "http://localhost/LoanService"); explanationAttr.Value = explanation; details.Attributes.Append(nameAttr); details.Attributes.Append(errorTypeAttr); details.Attributes.Append(explanationAttr); node.AppendChild(details); return(node); }
public override string ToText(Subtitle subtitle, string title) { string xmlStructure = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + Environment.NewLine + "<root fps=\"25\" movie=\"program title\" language=\"GBR:English (UK)\" font=\"Arial\" style=\"normal\" size=\"48\">" + Environment.NewLine + "<reel start=\"\" first=\"\" last=\"\">" + Environment.NewLine + "</reel>" + Environment.NewLine + "</root>"; XmlDocument xml = new XmlDocument(); xml.LoadXml(xmlStructure); XmlNode reel = xml.DocumentElement.SelectSingleNode("reel"); foreach (Paragraph p in subtitle.Paragraphs) { XmlNode paragraph = xml.CreateElement("title"); XmlAttribute start = xml.CreateAttribute("start"); start.InnerText = ToTimeCode(p.StartTime.TotalMilliseconds); paragraph.Attributes.Append(start); XmlAttribute end = xml.CreateAttribute("end"); end.InnerText = ToTimeCode(p.EndTime.TotalMilliseconds); paragraph.Attributes.Append(end); paragraph.InnerText = Utilities.RemoveHtmlTags(p.Text.Replace(Environment.NewLine, "|")); reel.AppendChild(paragraph); } return ToUtf8XmlString(xml); }
public override string ToText(Subtitle subtitle, string title) { string xmlStructure = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + Environment.NewLine + "<USFSubtitles version=\"1.0\">" + Environment.NewLine + @"<metadata> <title>Universal Subtitle Format</title> <author> <name>SubtitleEdit</name> <email>[email protected]</email> <url>http://www.nikse.dk/</url> </author>" + Environment.NewLine + " <language code=\"eng\">English</language>" + Environment.NewLine + @" <date>[DATE]</date> <comment>This is a USF file</comment> </metadata> <styles> <!-- Here we redefine the default style -->" + Environment.NewLine + " <style name=\"Default\">" + Environment.NewLine + " <fontstyle face=\"Arial\" size=\"24\" color=\"#FFFFFF\" back-color=\"#AAAAAA\" />" + Environment.NewLine + " <position alignment=\"BottomCenter\" vertical-margin=\"20%\" relative-to=\"Window\" />" + @" </style> </styles> <subtitles> </subtitles> </USFSubtitles>"; xmlStructure = xmlStructure.Replace("[DATE]", DateTime.Now.ToString("yyyy-MM-dd")); var xml = new XmlDocument(); xml.LoadXml(xmlStructure); xml.DocumentElement.SelectSingleNode("metadata/title").InnerText = title; var subtitlesNode = xml.DocumentElement.SelectSingleNode("subtitles"); foreach (Paragraph p in subtitle.Paragraphs) { XmlNode paragraph = xml.CreateElement("subtitle"); XmlAttribute start = xml.CreateAttribute("start"); start.InnerText = p.StartTime.ToString().Replace(",", "."); paragraph.Attributes.Prepend(start); XmlAttribute stop = xml.CreateAttribute("stop"); stop.InnerText = p.EndTime.ToString().Replace(",", "."); paragraph.Attributes.Append(stop); XmlNode text = xml.CreateElement("text"); text.InnerText = Utilities.RemoveHtmlTags(p.Text); paragraph.AppendChild(text); XmlAttribute style = xml.CreateAttribute("style"); style.InnerText = "Default"; text.Attributes.Append(style); subtitlesNode.AppendChild(paragraph); } return ToUtf8XmlString(xml); }
public System.Xml.XmlDocument CreatePackagesDotConfigFile(IEnumerable<Models.NugetPackageInfo> packages) { XmlDocument doc = new XmlDocument(); XmlDeclaration xmlDeclaration = doc.CreateXmlDeclaration("1.0", "UTF-8", null); XmlElement root = doc.DocumentElement; doc.InsertBefore(xmlDeclaration, root); XmlElement packagesElement = doc.CreateElement(string.Empty, "packages", string.Empty); doc.AppendChild(packagesElement); foreach (NugetPackageInfo package in packages) { XmlElement packageElement = doc.CreateElement(string.Empty, "package", string.Empty); packagesElement.AppendChild(packageElement); XmlAttribute idAttribute = doc.CreateAttribute("id"); idAttribute.Value = package.Info.Name; packageElement.Attributes.Append(idAttribute); XmlAttribute versionAttribute = doc.CreateAttribute("version"); versionAttribute.Value = package.Info.VersionNumber.ToString(); packageElement.Attributes.Append(versionAttribute); XmlAttribute frameworkAttribute = doc.CreateAttribute("targetFramework"); frameworkAttribute.Value = "net45"; packageElement.Attributes.Append(frameworkAttribute); } return doc; }
public override string ToText(Subtitle subtitle, string title) { string xmlStructure = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + Environment.NewLine + "<Data autoStart=\"true\" contentPath=\"\" />"; XmlDocument xml = new XmlDocument(); xml.LoadXml(xmlStructure); foreach (Paragraph p in subtitle.Paragraphs) { XmlNode paragraph = xml.CreateElement("Cue"); XmlAttribute start = xml.CreateAttribute("value"); start.InnerText = string.Format("{0}", p.StartTime.TotalMilliseconds); paragraph.Attributes.Append(start); XmlAttribute duration = xml.CreateAttribute("lineBreakBefore"); duration.InnerText = "true"; paragraph.Attributes.Append(duration); paragraph.InnerText = p.Text; xml.DocumentElement.AppendChild(paragraph); } return ToUtf8XmlString(xml); }
public static string AddEditInventoryItem(InventoryItem inventoryItem, string xmlFileName) { string success = "ono"; try { XmlDocument xdoc = new XmlDocument(); xdoc.Load(xmlFileName); XmlNode InventoryNode = xdoc.SelectSingleNode("//Inventory"); XmlNode InventoryItemNode; if (inventoryItem.ItemId == null) { InventoryItemNode = xdoc.CreateElement("Item"); inventoryItem.ItemId = Guid.NewGuid().ToString(); XmlAttribute ItemId = xdoc.CreateAttribute("Id"); ItemId.InnerText = inventoryItem.ItemId; InventoryItemNode.Attributes.Append(ItemId); XmlAttribute ItemType = xdoc.CreateAttribute("Type"); ItemType.InnerText = inventoryItem.ItemType; InventoryItemNode.Attributes.Append(ItemType); XmlAttribute Desc = xdoc.CreateAttribute("Desc"); Desc.InnerText = inventoryItem.ItemDesc; InventoryItemNode.Attributes.Append(Desc); XmlAttribute Location = xdoc.CreateAttribute("Location"); Location.InnerText = inventoryItem.ItemLoc; InventoryItemNode.Attributes.Append(Location); XmlAttribute ItemDetail = xdoc.CreateAttribute("ItemDetail"); ItemDetail.InnerText = inventoryItem.ItemDetail; InventoryItemNode.Attributes.Append(ItemDetail); InventoryNode.AppendChild(InventoryItemNode); } else { InventoryItemNode = xdoc.SelectSingleNode("//Inventory//Item[@Id='" + inventoryItem.ItemId + "']"); InventoryItemNode.Attributes["Type"].InnerText = inventoryItem.ItemType; InventoryItemNode.Attributes["Desc"].InnerText = inventoryItem.ItemDesc; InventoryItemNode.Attributes["Location"].InnerText = inventoryItem.ItemLoc; InventoryItemNode.Attributes["ItemDetail"].InnerText = inventoryItem.ItemDetail; } xdoc.Save(xmlFileName); success = "ok"; } catch (Exception ex) { success = "ERROR: " + ex.Message; } return success; }
public static string SaveToFile () { string title; string[] fragments; XmlDocument doc; XmlElement item; XmlAttribute subject_attr, body_attr, contrib_attr; fragments = subject.Split (' '); title = null; foreach (string s in fragments) { title += s; } doc = new XmlDocument (); doc.AppendChild (doc.CreateProcessingInstruction ("xml", "version='1.0'")); item = doc.CreateElement ("mwnitem"); subject_attr = doc.CreateAttribute ("subject"); subject_attr.Value = subject; body_attr = doc.CreateAttribute ("body"); body_attr.Value = @body; contrib_attr = doc.CreateAttribute ("contrib"); contrib_attr.Value = @contrib; item.Attributes.Append (subject_attr); item.Attributes.Append (body_attr); item.Attributes.Append (contrib_attr); doc.AppendChild (item); doc.Save ((title = title.Substring (0, 8)) + ".mwnitem"); return title; }
public override string ToText(Subtitle subtitle, string title) { string xmlStructure = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + Environment.NewLine + "<uts>" + Environment.NewLine + "</uts>"; var xml = new XmlDocument(); xml.LoadXml(xmlStructure); XmlNode root = xml.DocumentElement; foreach (Paragraph p in subtitle.Paragraphs) { //<ut secOut="26.4" secIn="21.8"> // <![CDATA[Pozdrav i dobrodošli natrag<br>u drugi dio naše emisije]]> //</ut> XmlNode ut = xml.CreateElement("ut"); XmlAttribute et = xml.CreateAttribute("secOut"); et.InnerText = string.Format("{0:0.0##}", p.EndTime.TotalSeconds).Replace(",", "."); ut.Attributes.Append(et); XmlAttribute st = xml.CreateAttribute("secIn"); st.InnerText = string.Format("{0:0.0##}", p.StartTime.TotalSeconds).Replace(",", "."); ut.Attributes.Append(st); ut.InnerText = p.Text; ut.InnerXml = "<![CDATA[" + ut.InnerXml.Replace(Environment.NewLine, "<br>") + "]]>"; root.AppendChild(ut); } return ToUtf8XmlString(xml); }
private void btn_OK_Click(object sender, EventArgs e) { XmlDocument xmlDoc = new XmlDocument(); XmlNode docNode = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", null); xmlDoc.AppendChild(docNode); XmlNode version = xmlDoc.CreateElement("version"); xmlDoc.AppendChild(version); XmlNode sbtNode = xmlDoc.CreateElement("SBT"); XmlAttribute sbtAttribute = xmlDoc.CreateAttribute("Path"); sbtAttribute.Value = textBox1.Text; sbtNode.Attributes.Append(sbtAttribute); version.AppendChild(sbtNode); XmlNode garenaNode = xmlDoc.CreateElement("Garena"); XmlAttribute garenaAttribute = xmlDoc.CreateAttribute("Path"); garenaAttribute.Value = textBox2.Text; garenaNode.Attributes.Append(garenaAttribute); version.AppendChild(garenaNode); XmlNode superNode = xmlDoc.CreateElement("Super"); XmlAttribute superAttribute = xmlDoc.CreateAttribute("Path"); superAttribute.Value = textBox3.Text; superNode.Attributes.Append(superAttribute); version.AppendChild(superNode); xmlDoc.Save("path"); this.Close(); }
/// <summary> /// XML-Datei mit XmlDocument erstellen. /// </summary> static void CreateXmlDocument() { XmlDocument xmlDoc = new XmlDocument(); XmlDeclaration declaration = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", "no"); // XML Deklaration xmlDoc.AppendChild(declaration); XmlNode rootNode = xmlDoc.CreateElement("books"); // Wurzelelement xmlDoc.AppendChild(rootNode); // Wurzelelement zum Dokument hinzufuegen // <book> Element XmlNode userNode = xmlDoc.CreateElement("book"); // mit einem Attribut XmlAttribute attribute = xmlDoc.CreateAttribute("release"); attribute.Value = "2013/02/15"; userNode.Attributes.Append(attribute); // Attribut zum <book> Ele hinzufuegen // und Textinhalt userNode.InnerText = "Elizabeth Corley - Pretty Little Things"; rootNode.AppendChild(userNode); // Textinhalt zum <book> Ele hinzufuegen // und noch ein <book> userNode = xmlDoc.CreateElement("book"); attribute = xmlDoc.CreateAttribute("release"); attribute.Value = "2011/11/11"; userNode.Attributes.Append(attribute); userNode.InnerText = "Stephen Hawking - A Brief History Of Time"; rootNode.AppendChild(userNode); // XML Dokument speichern xmlDoc.Save("xmlDocument_books.xml"); // in ../projectname/bin/debug/ }
protected override bool OnExecute(ServerActionContext context) { DateTime scheduledTime = Platform.Time; if (_exprScheduledTime != null) { scheduledTime = Evaluate(_exprScheduledTime, context, scheduledTime); } scheduledTime = CalculateOffsetTime(scheduledTime, _offsetTime, _units); XmlDocument doc = new XmlDocument(); XmlElement element = doc.CreateElement("compress"); doc.AppendChild(element); XmlAttribute syntaxAttribute = doc.CreateAttribute("syntax"); syntaxAttribute.Value = TransferSyntax.Jpeg2000ImageCompressionUid; element.Attributes.Append(syntaxAttribute); syntaxAttribute = doc.CreateAttribute("ratio"); syntaxAttribute.Value = _ratio.ToString(); element.Attributes.Append(syntaxAttribute); Platform.Log(LogLevel.Debug, "Jpeg 2000 Lossy Compression Scheduling: This study will be compressed on {0}", scheduledTime); context.CommandProcessor.AddCommand( new InsertFilesystemQueueCommand(_queueType, context.FilesystemKey, context.StudyLocationKey, scheduledTime, doc)); return true; }
/// <summary> /// Generates an Xml element for this rule /// </summary> /// <param name="doc">The parent Xml document</param> /// <returns>XmlNode representing this rule</returns> public override System.Xml.XmlNode Serialize(System.Xml.XmlDocument doc) { string xmlString = "<friendlyRule>" + friendlyRule + "</friendlyRule>" + "<assignmentType>" + ((int)assignmentType).ToString() + "</assignmentType>" + "<destinationColumnName>" + destinationColumnName + "</destinationColumnName>" + "<destinationColumnType>" + destinationColumnType + "</destinationColumnType>"; xmlString = xmlString + "<parameterList>"; foreach (string parameter in this.AssignmentParameters) { xmlString = xmlString + "<parameter>" + parameter + "</parameter>"; } xmlString = xmlString + "</parameterList>"; System.Xml.XmlElement element = doc.CreateElement("rule"); element.InnerXml = xmlString; System.Xml.XmlAttribute order = doc.CreateAttribute("order"); System.Xml.XmlAttribute type = doc.CreateAttribute("ruleType"); type.Value = "EpiDashboard.Rules.Rule_SimpleAssign"; element.Attributes.Append(type); return(element); }
public override string ToText(Subtitle subtitle, string title) { string xmlStructure = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + Environment.NewLine + "<transcript/>"; var xml = new XmlDocument(); xml.LoadXml(xmlStructure); foreach (Paragraph p in subtitle.Paragraphs) { XmlNode paragraph = xml.CreateElement("text"); XmlAttribute start = xml.CreateAttribute("start"); start.InnerText = string.Format("{0}", p.StartTime.TotalMilliseconds / 1000).Replace(",", "."); paragraph.Attributes.Append(start); XmlAttribute duration = xml.CreateAttribute("dur"); duration.InnerText = string.Format("{0}", p.Duration.TotalMilliseconds / 1000).Replace(",", "."); paragraph.Attributes.Append(duration); paragraph.InnerText = p.Text; xml.DocumentElement.AppendChild(paragraph); } return ToUtf8XmlString(xml); }
public static Committee AddEditCommittee(Committee committee, string xmlFileName) { try { XmlDocument xdoc = new XmlDocument(); xdoc.Load(xmlFileName); XmlNode CommitteesNode = xdoc.SelectSingleNode("//Committees"); XmlNode committeeNode; if (committee.CommitteeId == null) { committeeNode = xdoc.CreateElement("Committee"); committee.CommitteeId = Guid.NewGuid().ToString(); XmlAttribute committeeId = xdoc.CreateAttribute("Id"); committeeId.InnerText = committee.CommitteeId; committeeNode.Attributes.Append(committeeId); XmlAttribute committeeName = xdoc.CreateAttribute("Name"); committeeName.InnerText = committee.CommitteeName; committeeNode.Attributes.Append(committeeName); XmlAttribute committeeType = xdoc.CreateAttribute("Type"); committeeType.InnerText = committee.CommitteeType; committeeNode.Attributes.Append(committeeType); XmlAttribute masonicYear = xdoc.CreateAttribute("MasonicYear"); masonicYear.InnerText = committee.MasonicYear; committeeNode.Attributes.Append(masonicYear); CommitteesNode.AppendChild(committeeNode); } else { committeeNode = xdoc.SelectSingleNode("//Committees//Committee[@Id='" + committee.CommitteeId + "']"); committeeNode.Attributes["Name"].InnerText = committee.CommitteeName; committeeNode.Attributes["Type"].InnerText = committee.CommitteeType; committeeNode.Attributes["MasonicYear"].InnerText = committee.MasonicYear; } xdoc.Save(xmlFileName); } catch (Exception ex) { committee.CommitteeId = "ERROR: " + ex.Message; } return committee; }
/// <summary> /// Adds expiration record to the SQLFileCache /// </summary> public static void AddFileExpiration(string Key, ref SQLOptions o) { string strXMLXPath = "/SQLHelper_FileExpirations/File"; string strXMLForeignKeyAttribute = "Key"; System.Xml.XmlDocument doc = GetFileExpirations(ref o); o.WriteToLog("updating expiration file for this value..." + Key); General.Debug.Trace("updating expiration file for this value..." + Key); System.Xml.XmlNode node = doc.SelectSingleNode(strXMLXPath + "[@" + strXMLForeignKeyAttribute + "='" + Key + "']"); if (node == null) { o.WriteToLog("record not found... creating..." + Key); General.Debug.Trace("record not found... creating..." + Key); node = doc.CreateNode(System.Xml.XmlNodeType.Element, "File", ""); node.Attributes.Append(doc.CreateAttribute("Key")); node.Attributes["Key"].Value = Key; node.Attributes.Append(doc.CreateAttribute("ExpirationDate")); node.Attributes["ExpirationDate"].Value = o.Expiration.ToString(); doc.DocumentElement.AppendChild(node); } else { o.WriteToLog("record found... updating..." + Key); General.Debug.Trace("record found... updating..." + Key); node.Attributes["ExpirationDate"].Value = o.Expiration.ToString(); } SaveFileExpirations(doc, ref o); }
public static List<XmlNode> GetGraphicsAsXmlNode(List<Funclet> lstFuncs) { string strAttX = "X"; string strAttY = "Y"; string strID = "ID"; XmlNameTable nameTable = CreateNameTable(lstFuncs); XmlDocument xslDoc = new XmlDocument(nameTable); List<XmlNode> lstNode = new List<XmlNode>(); foreach (Funclet item in lstFuncs) { string nodeName = item.FunctionName.Replace("'", "").Replace(" ", "_"); var node = xslDoc.CreateElement(nodeName); var attLocationX = xslDoc.CreateAttribute(strAttX); attLocationX.Value = item.X.ToString(); var attLocationY = xslDoc.CreateAttribute(strAttY); attLocationY.Value = item.Y.ToString(); var attId = xslDoc.CreateAttribute(strID); attId.Value = item.ID.ToString(); node.Attributes.Append(attLocationX); node.Attributes.Append(attLocationY); node.Attributes.Append(attId); lstNode.Add(node); } return lstNode; }
protected void btnAdd_Click(object sender, EventArgs e) { string xmlPath = Server.MapPath("RSSFeed.xml"); XmlDocument doc = new XmlDocument(); doc.Load(xmlPath); XmlNode feed = doc.CreateElement("Feed"); XmlAttribute attribute = doc.CreateAttribute("Title"); attribute.Value = txtTitle.Text.Trim(); feed.Attributes.Append(attribute); attribute = doc.CreateAttribute("Category"); attribute.Value = drpCategory.Text.Trim(); feed.Attributes.Append(attribute); attribute = doc.CreateAttribute("URL"); attribute.Value = txtUrl.Text.Trim(); feed.Attributes.Append(attribute); doc.DocumentElement.AppendChild(feed); doc.Save(xmlPath); Response.Redirect("RSSReader.aspx"); }
public override string ToText(Subtitle subtitle, string title) { // <Phrase TimeStart="4020" TimeEnd="6020"> // <Text>XYZ PRESENTS</Text> // </Phrase> string xmlStructure = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + Environment.NewLine + "<Subtitle xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"></Subtitle>"; XmlDocument xml = new XmlDocument(); xml.LoadXml(xmlStructure); int id = 1; foreach (Paragraph p in subtitle.Paragraphs) { XmlNode paragraph = xml.CreateElement("Phrase"); XmlAttribute start = xml.CreateAttribute("TimeStart"); start.InnerText = p.StartTime.TotalMilliseconds.ToString(); paragraph.Attributes.Append(start); XmlAttribute duration = xml.CreateAttribute("TimeEnd"); duration.InnerText = p.EndTime.TotalMilliseconds.ToString(); paragraph.Attributes.Append(duration); XmlNode text = xml.CreateElement("Text"); text.InnerText = HtmlUtil.RemoveHtmlTags(p.Text).Replace(Environment.NewLine, "\\n"); paragraph.AppendChild(text); xml.DocumentElement.AppendChild(paragraph); id++; } return ToUtf8XmlString(xml); }
static XmlDocument AddOrModifyAppSettings(XmlDocument xmlDoc, string key, string value) { bool isNew = false; XmlNodeList list = xmlDoc.DocumentElement.SelectNodes(string.Format("appSettings/add[@key='{0}']", key)); XmlNode node; isNew = list.Count == 0; if (isNew) { node = xmlDoc.CreateNode(XmlNodeType.Element, "add", null); XmlAttribute attribute = xmlDoc.CreateAttribute("key"); attribute.Value = key; node.Attributes.Append(attribute); attribute = xmlDoc.CreateAttribute("value"); attribute.Value = value; node.Attributes.Append(attribute); xmlDoc.DocumentElement.SelectNodes("appSettings")[0].AppendChild(node); } else { node = list[0]; node.Attributes["value"].Value = value; } return xmlDoc; }
/// <summary> /// Creates the FetchXML Query. /// </summary> /// <param name="xml">The FetchXMLQuery.</param> /// <param name="cookie">The paging cookie.</param> /// <param name="page">The page number.</param> /// <param name="count">The records per page count.</param> /// <returns>Formatted FechXML Query</returns> protected string CreateXml(string xml, string cookie, int page, int count) { StringReader stringReader = new StringReader(xml); XmlTextReader reader = new XmlTextReader(stringReader); // Load document XmlDocument doc = new XmlDocument(); doc.Load(reader); XmlAttributeCollection attrs = doc.DocumentElement.Attributes; if (cookie != null) { XmlAttribute pagingAttr = doc.CreateAttribute("paging-cookie"); pagingAttr.Value = cookie; attrs.Append(pagingAttr); } XmlAttribute pageAttr = doc.CreateAttribute("page"); pageAttr.Value = System.Convert.ToString(page); attrs.Append(pageAttr); XmlAttribute countAttr = doc.CreateAttribute("count"); countAttr.Value = System.Convert.ToString(count); attrs.Append(countAttr); StringBuilder sb = new StringBuilder(1024); StringWriter stringWriter = new StringWriter(sb); XmlTextWriter writer = new XmlTextWriter(stringWriter); doc.WriteTo(writer); writer.Close(); return sb.ToString(); }
public static void ExportProfile(GarminProfile profile, Stream exportStream) { Debug.Assert(exportStream.CanWrite && exportStream.Length == 0); XmlDocument document = new XmlDocument(); XmlNode database; XmlAttribute attribute; document.AppendChild(document.CreateXmlDeclaration("1.0", "UTF-8", "no")); database = document.CreateNode(XmlNodeType.Element, "TrainingCenterDatabase", null); document.AppendChild(database); // xmlns namespace attribute attribute = document.CreateAttribute("xmlns"); attribute.Value = "http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2"; database.Attributes.Append(attribute); // xmlns:xsi namespace attribute attribute = document.CreateAttribute("xmlns", "xsi", Constants.xmlns); attribute.Value = Constants.xsins; database.Attributes.Append(attribute); // xsi:schemaLocation namespace attribute attribute = document.CreateAttribute("xsi", "schemaLocation", Constants.xsins); attribute.Value = "http://www.garmin.com/xmlschemas/ProfileExtension/v1 http://www.garmin.com/xmlschemas/UserProfilePowerExtensionv1.xsd http://www.garmin.com/xmlschemas/ProfileExtension/v2 http://www.garmin.com/xmlschemas/UserProfilePowerExtensionv2.xsd http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2 http://www.garmin.com/xmlschemas/TrainingCenterDatabasev2.xsd http://www.garmin.com/xmlschemas/UserProfile/v2 http://www.garmin.com/xmlschemas/UserProfileExtensionv2.xsd"; database.Attributes.Append(attribute); XmlNode extensionsNode = document.CreateElement(Constants.ExtensionsTCXString, null); database.AppendChild(extensionsNode); profile.Serialize(extensionsNode, "", document); document.Save(new StreamWriter(exportStream)); }
public void AddNodeToXml1(string xmlFile) { //加载xml文件,并选出要添加子节点的节点 XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(xmlFile);//不会覆盖原有内容 //xmlDoc.LoadXml("<Settings><Set></Set></Settings>");//会覆盖原有内容 XmlNode parentNode = xmlDoc.SelectSingleNode(@"Settings/Set"); //创建节点,并设置节点属性 XmlElement addNode = xmlDoc.CreateElement("Log"); XmlAttribute addNodeName = xmlDoc.CreateAttribute("Name"); addNodeName.InnerText = "全方位日志2"; XmlAttribute addNodeUrl = xmlDoc.CreateAttribute("Url"); addNodeUrl.InnerText = @"E:\vmware_linux_file\test\Working\TianJin\log2"; XmlAttribute addNodeSaveDays = xmlDoc.CreateAttribute("SaveDays"); addNodeSaveDays.InnerText = "5"; addNode.SetAttributeNode(addNodeName); addNode.SetAttributeNode(addNodeUrl); addNode.SetAttributeNode(addNodeSaveDays); //将新建的子节点挂在到要加载的节点上 parentNode.AppendChild(addNode); xmlDoc.Save(xmlFile); }
//Saves given Unistroke to file as a new gesture with name specified public static void saveGesture(ref SignalProcessing.Unistroke<double> u, string name) { XmlDocument doc = new XmlDocument(); doc.Load("gestures.xml"); XmlNodeList nl = doc.GetElementsByTagName("gesture_set"); XmlElement gesture_elem= doc.CreateElement("gesture"); XmlAttribute ident = doc.CreateAttribute("name"); ident.InnerText = name; gesture_elem.Attributes.Append(ident); for(int i = 0; i < u.trace.Count; i++){ XmlElement n = doc.CreateElement("point"); XmlAttribute x = doc.CreateAttribute("x"); XmlAttribute y = doc.CreateAttribute("y"); XmlAttribute z = doc.CreateAttribute("z"); x.InnerText = u[i].x.ToString(); y.InnerText = u[i].y.ToString(); z.InnerText = u[i].z.ToString(); n.Attributes.Append(x); n.Attributes.Append(y); n.Attributes.Append(z); gesture_elem.AppendChild(n); } nl[0].AppendChild(gesture_elem); doc.Save("gestures.xml"); }
public override string ToText(Subtitle subtitle, string title) { string xmlStructure = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + Environment.NewLine + "<tt>" + Environment.NewLine + " <div>" + Environment.NewLine + " </div>" + Environment.NewLine + "</tt>"; var xml = new XmlDocument(); xml.LoadXml(xmlStructure); XmlNode div = xml.DocumentElement.SelectSingleNode("div"); foreach (Paragraph p in subtitle.Paragraphs) { XmlNode paragraph = xml.CreateElement("p"); string text = HtmlUtil.RemoveHtmlTags(p.Text, true); paragraph.InnerText = text; paragraph.InnerXml = "<![CDATA[<sub>" + paragraph.InnerXml.Replace(Environment.NewLine, "<br />") + "</sub>]]>"; XmlAttribute start = xml.CreateAttribute("begin"); start.InnerText = ConvertToTimeString(p.StartTime); paragraph.Attributes.Append(start); XmlAttribute end = xml.CreateAttribute("end"); end.InnerText = ConvertToTimeString(p.EndTime); paragraph.Attributes.Append(end); div.AppendChild(paragraph); } return ToUtf8XmlString(xml); }
private void GetRssFiles() { XmlDocument xdoc = new XmlDocument(); XmlElement xRoot = xdoc.CreateElement("Data"); xdoc.AppendChild(xRoot); string[] colFileInfos = Directory.GetFiles(Server.MapPath("~/UI/RSS/Categories"), "*.xml", SearchOption.AllDirectories); for (int i = 0; i < colFileInfos.Length; i++) { XmlElement xRow = xdoc.CreateElement("File"); xRoot.AppendChild(xRow); XmlAttribute xAttpath = xdoc.CreateAttribute("Path"); xRow.Attributes.Append(xAttpath); XmlAttribute xAttname = xdoc.CreateAttribute("Name"); xRow.Attributes.Append(xAttname); xAttname.Value = colFileInfos[i].Substring(colFileInfos[i].LastIndexOf('\\') + 1, colFileInfos[i].Length - colFileInfos[i].LastIndexOf('\\') - 1).Replace("rss", "").Replace("-", "").Replace(".xml", "").Replace("//", "/"); xAttpath.Value ="change me" + "/UI/RSS/Categories" + colFileInfos[i].Substring(colFileInfos[i].LastIndexOf('\\'), colFileInfos[i].Length - colFileInfos[i].LastIndexOf('\\')).Replace("//", "/"); } XslTemplate xsl = XslTemplateManager.GetByID(XSLID); if (null == xsl) return; dvData.InnerHtml = UtilitiesManager.TransformXMLWithXSLText(xdoc.OuterXml, xsl.Details); }
public static string GetPartInfoXMLRequest(string cliinfo,string productid) { XmlDocument doc = new XmlDocument(); XmlElement root,node,node_1; XmlDeclaration dec; // doc.CreateXmlDeclaration("1.0", "utf-8", null); doc.AppendChild(dec= doc.CreateXmlDeclaration("1.0", "", "")); root= doc.CreateElement("REQ"); doc.AppendChild(root); node= doc.CreateElement("CLIINFO"); node.InnerText = cliinfo; root.AppendChild(node); node = doc.CreateElement("FUNCTION"); node.InnerText="PT000V_PartInfo"; root.AppendChild(node); node = doc.CreateElement("VERSION"); node.InnerText = "1.0.0.0"; root.AppendChild(node); node=doc.CreateElement("ELE"); XmlAttribute attr=doc.CreateAttribute("NAME"); attr.Value="PARTINFO"; node.Attributes.Append(attr); attr = doc.CreateAttribute("NAME"); attr.Value = "PARTINFO"; node_1=doc.CreateElement("ATTR"); node_1.Attributes.Append(attr); node_1.InnerText=productid; node.AppendChild(node_1); root.AppendChild(node); return doc.InnerXml; }
/// <summary> /// Generates an XML containing WMTS capabilities. /// </summary> /// <param name="map">A MapAround.Mapping.Map instance</param> /// <param name="serviceDescription"></param> /// <returns>A System.Xml.XmlDocument instance containing WMTS capabilities in compliance to the WMS standard</returns> public static XmlDocument GetCapabilities(Map map, WmtsServiceDescription serviceDescription) { XmlDocument capabilities = new XmlDocument(); capabilities.InsertBefore(capabilities.CreateXmlDeclaration("1.0", "UTF-8", string.Empty), capabilities.DocumentElement); XmlNode rootNode = capabilities.CreateNode(XmlNodeType.Element, "WMTS_Capabilities", wmtsNamespaceURI); rootNode.Attributes.Append(createAttribute("version", "1.0.0", capabilities)); XmlAttribute attr = capabilities.CreateAttribute("xmlns", "xsi", "http://www.w3.org/2000/xmlns/"); attr.InnerText = "http://www.w3.org/2001/XMLSchema-instance"; rootNode.Attributes.Append(attr); rootNode.Attributes.Append(createAttribute("xmlns:xlink", xlinkNamespaceURI, capabilities)); XmlAttribute attr2 = capabilities.CreateAttribute("xsi", "schemaLocation", "http://www.w3.org/2001/XMLSchema-instance"); rootNode.AppendChild(GenerateServiceNode(ref serviceDescription, capabilities)); rootNode.AppendChild(GenerateCapabilityNode(map, serviceDescription, capabilities)); capabilities.AppendChild(rootNode); return capabilities; }
public override string ToText(Subtitle subtitle, string title) { string xmlStructure = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + Environment.NewLine + "<subtitle><config bgAlpha=\"0.5\" bgColor=\"0x000000\" defaultColor=\"0xCCffff\" fontSize=\"16\"/></subtitle>"; XmlDocument xml = new XmlDocument(); xml.LoadXml(xmlStructure); int id = 1; foreach (Paragraph p in subtitle.Paragraphs) { XmlNode paragraph = xml.CreateElement("entry"); XmlAttribute duration = xml.CreateAttribute("timeOut"); duration.InnerText = p.EndTime.ToString(); paragraph.Attributes.Append(duration); XmlAttribute start = xml.CreateAttribute("timeIn"); start.InnerText = p.StartTime.ToString(); paragraph.Attributes.Append(start); XmlAttribute idAttr = xml.CreateAttribute("id"); idAttr.InnerText = id.ToString(CultureInfo.InvariantCulture); paragraph.Attributes.Append(idAttr); paragraph.InnerText = "<![CDATA[" + p.Text + "]]"; xml.DocumentElement.AppendChild(paragraph); id++; } return ToUtf8XmlString(xml); }
/// <summary> /// persist the Oauth access token in OauthAccessTokenStorage.xml file /// </summary> internal static void StoreOauthAccessToken(Controller page) { string path = page.Server.MapPath("/") + @"OauthAccessTokenStorage.xml"; XmlDocument doc = new XmlDocument(); doc.Load(path); XmlNode node = doc.CreateElement("record"); XmlAttribute userMailIdAttribute = doc.CreateAttribute("usermailid"); userMailIdAttribute.Value = page.Session["FriendlyEmail"].ToString(); node.Attributes.Append(userMailIdAttribute); XmlAttribute accessKeyAttribute = doc.CreateAttribute("encryptedaccesskey"); string secuirtyKey = ConfigurationManager.AppSettings["securityKey"]; accessKeyAttribute.Value = CryptographyHelper.EncryptData(page.Session["accessToken"].ToString(), secuirtyKey); node.Attributes.Append(accessKeyAttribute); XmlAttribute encryptedaccesskeysecretAttribute = doc.CreateAttribute("encryptedaccesskeysecret"); encryptedaccesskeysecretAttribute.Value = CryptographyHelper.EncryptData(page.Session["accessTokenSecret"].ToString(), secuirtyKey); node.Attributes.Append(encryptedaccesskeysecretAttribute); XmlAttribute realmIdAttribute = doc.CreateAttribute("realmid"); realmIdAttribute.Value = page.Session["realm"].ToString(); node.Attributes.Append(realmIdAttribute); XmlAttribute dataSourceAttribute = doc.CreateAttribute("dataSource"); dataSourceAttribute.Value = page.Session["dataSource"].ToString(); node.Attributes.Append(dataSourceAttribute); doc.DocumentElement.AppendChild(node); doc.Save(path); }
/// <summary> /// Makes sure the necessary HTTP module is present in the web.config file to support /// device detection and image optimisation. /// </summary> /// <param name="xml">Xml fragment for the system.webServer web.config section</param> /// <returns>True if a change was made, otherwise false.</returns> private static bool FixAddModule(XmlDocument xml) { var changed = false; var module = xml.SelectSingleNode("//modules/add[@type='FiftyOne.Foundation.Mobile.Detection.DetectorModule, FiftyOne.Foundation']") as XmlElement; if (module != null) { // If image optimisation is enabled and the preCondition attribute // is present then it'll need to be removed. if (module.Attributes["preCondition"] != null) { module.Attributes.RemoveNamedItem("preCondition"); changed = true; } // Make sure the module entry is named "Detector". if ("Detector".Equals(module.GetAttribute("name")) == false) { module.Attributes["name"].Value = "Detector"; changed = true; } } else { // The module entry is missing so add a new one. var modules = xml.SelectSingleNode("//modules"); module = xml.CreateElement("add"); module.Attributes.Append(xml.CreateAttribute("name")); module.Attributes["name"].Value = "Detector"; module.Attributes.Append(xml.CreateAttribute("type")); module.Attributes["type"].Value = "FiftyOne.Foundation.Mobile.Detection.DetectorModule, FiftyOne.Foundation"; modules.InsertAfter(module, modules.LastChild); changed = true; } return changed; }
public static void Merge(XmlDocument doc) { var elements = new [] { Tuple.Create("Default", "diff", "application/octet" ), Tuple.Create("Default", "exe", "application/octet" ), Tuple.Create("Default", "dll", "application/octet" ), Tuple.Create("Default", "shasum", "text/plain" ), }; var typesElement = doc.FirstChild.NextSibling; if (typesElement.Name.ToLowerInvariant() != "types") { throw new Exception("Invalid ContentTypes file, expected root node should be 'Types'"); } var existingTypes = typesElement.ChildNodes.OfType<XmlElement>() .Select(k => Tuple.Create(k.Name, k.GetAttribute("Extension").ToLowerInvariant(), k.GetAttribute("ContentType").ToLowerInvariant())); var toAdd = elements .Where(x => existingTypes.All(t => t.Item2 != x.Item2.ToLowerInvariant())) .Select(element => { var ret = doc.CreateElement(element.Item1, typesElement.NamespaceURI); var ext = doc.CreateAttribute("Extension"); ext.Value = element.Item2; var ct = doc.CreateAttribute("ContentType"); ct.Value = element.Item3; ret.Attributes.Append(ext); ret.Attributes.Append(ct); return ret; }); foreach (var v in toAdd) typesElement.AppendChild(v); }
// Provides methods for structuring xml to produce an Svg (nested in an HTML doc). public SvgXmlBuilder() { HtmlDoc = new XmlDocument (); // HTML-level HtmlDoc.AppendChild (HtmlDoc.CreateDocumentType ("html", "", "", "")); htmlDocElement = HtmlDoc.CreateElement ("html"); // Body-level bodyElement = HtmlDoc.CreateElement ("body"); htmlDocElement.AppendChild (bodyElement); // svg document SvgElement = HtmlDoc.CreateElement ("svg"); bodyElement.AppendChild (SvgElement); var svgName = HtmlDoc.CreateAttribute ("name"); svgName.Value = "Geographical Region Statistic Map"; SvgElement.Attributes.Append (svgName); // Attributes independent of data. var heightAttr = HtmlDoc.CreateAttribute ("height"); heightAttr.Value = "100%"; var widthAttr = HtmlDoc.CreateAttribute ("width"); widthAttr.Value = "100%"; SvgElement.Attributes.Append (heightAttr); SvgElement.Attributes.Append (widthAttr); // TODO: Use css/jquery-style formatting? //new Style var svgColorAttr = HtmlDoc.CreateAttribute ("style"); svgColorAttr.Value = "background:black"; SvgElement.Attributes.Append (svgColorAttr); }
public override string ToText(Subtitle subtitle, string title) { string xmlStructure = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + Environment.NewLine + "<EEG708Captions/>"; XmlDocument xml = new XmlDocument(); xml.LoadXml(xmlStructure); foreach (Paragraph p in subtitle.Paragraphs) { XmlNode paragraph = xml.CreateElement("Caption"); XmlAttribute start = xml.CreateAttribute("timecode"); start.InnerText = EncodeTimeCode(p.StartTime); paragraph.Attributes.Append(start); XmlNode text = xml.CreateElement("Text"); text.InnerText = p.Text; paragraph.AppendChild(text); xml.DocumentElement.AppendChild(paragraph); paragraph = xml.CreateElement("Caption"); start = xml.CreateAttribute("timecode"); start.InnerText = EncodeTimeCode(p.EndTime); paragraph.Attributes.Append(start); xml.DocumentElement.AppendChild(paragraph); } return ToUtf8XmlString(xml); }
private static async System.Threading.Tasks.Task UpdateCRMOnlineIPs(bool force) { if (LastCRMOnlineIPUpdate.AddHours(12) <= DateTime.Now | force) { String CRMOnlineStep1 = await GetIPsasString(new Uri("https://support.microsoft.com/api/content/kb/2655102")); System.Xml.XmlDocument _result = new System.Xml.XmlDocument(); XmlElement root = _result.CreateElement("crmonline"); _result.AppendChild(root); System.Net.Http.HttpClient client = new System.Net.Http.HttpClient(); String CRMOnlineStep2 = RemoveStrayHTML(CRMOnlineStep1); //this splits everything into 7 objects string[] stringSeparators = new string[] { "<span class='text-base'>" }; String[] CRMOnlineStep3 = CRMOnlineStep2.Split(stringSeparators, StringSplitOptions.None); //since the first one is all the text *before* the URLs, //we can drop the first one foreach (String org in CRMOnlineStep3.Skip(1)) { //now, split it on <br/> //skip the first one String url1; XmlElement region = _result.CreateElement("region"); XmlAttribute regionname = _result.CreateAttribute("name"); regionname.Value = org.Substring(0, org.IndexOf("based organizations")).Replace(" area", "").Trim(); region.Attributes.Append(regionname); //build the addresslist type attribute XmlElement addressTypeNode = _result.CreateElement("addresslist"); XmlAttribute addressTypeName = _result.CreateAttribute("type"); addressTypeName.Value = "url"; addressTypeNode.Attributes.Append(addressTypeName); foreach (string url0 in org.Split(new string[] { @"<br/>" }, StringSplitOptions.None).Skip(1)) { if (url0.Length > 0) { url1 = ReplaceNonPrintableCharacters(url0); System.Diagnostics.Debug.WriteLine("org: " + org.Substring(0, org.IndexOf(":"))); System.Diagnostics.Debug.WriteLine(url1.IndexOf(@"://")); if (url1.IndexOf(@"://") > 0 && url1.IndexOf(@"://") < 7) { url1 = url1.Substring(url1.IndexOf("h")); XmlElement urlnode = _result.CreateElement("address"); urlnode.InnerText = url1; addressTypeNode.AppendChild(urlnode); } } } region.AppendChild(addressTypeNode); root.AppendChild(region); } CRMOnlineIPs = _result; LastCRMOnlineIPUpdate = DateTime.UtcNow; } }
public System.Xml.XmlNode SerializeToXML(System.Xml.XmlDocument xdoc) { XmlNode xn = xdoc.CreateElement("Point"); xn.Attributes.Append(xdoc.CreateAttribute("X")).Value = _X.ToString(nfi); xn.Attributes.Append(xdoc.CreateAttribute("Y")).Value = _Y.ToString(nfi); return(xn); }
public System.Xml.XmlNode SerializeToXML(System.Xml.XmlDocument xdoc) { XmlNode xn = xdoc.CreateElement("Tone"); xn.Attributes.Append(xdoc.CreateAttribute("R")).Value = mR.ToString(nfi); xn.Attributes.Append(xdoc.CreateAttribute("G")).Value = mG.ToString(nfi); xn.Attributes.Append(xdoc.CreateAttribute("B")).Value = mB.ToString(nfi); return(xn); }
public void WriteLocalSetting(string sectionName, string settingName, string settingValue) { string sectionNameValid = RemoveInvalidXmlChars(sectionName); string settingNameValid = RemoveInvalidXmlChars(settingName); if (ConfigDocument == null) { ConfigDocument = new System.Xml.XmlDocument(); if (System.IO.File.Exists(ConfigFileName)) { ConfigDocument.Load(ConfigFileName); } else { ConfigDocument.AppendChild(ConfigDocument.CreateElement("LocalConfig")); } } lock (ConfigDocument) { if (ConfigDocument.DocumentElement == null) { ConfigDocument.LoadXml("<?xml version='1.0' ?><LocalConfig></LocalConfig>"); } System.Xml.XmlAttribute Attribute; System.Xml.XmlNode SectionNode = ConfigDocument.SelectSingleNode("/LocalConfig/Section[@name='" + sectionNameValid + "']"); if (SectionNode == null) { //Crear la sección SectionNode = ConfigDocument.CreateElement("Section"); Attribute = ConfigDocument.CreateAttribute("name"); Attribute.Value = sectionNameValid; SectionNode.Attributes.Append(Attribute); ConfigDocument.DocumentElement.AppendChild(SectionNode); } System.Xml.XmlNode SettingNode = ConfigDocument.SelectSingleNode("/LocalConfig/Section[@name='" + sectionNameValid + "']/Setting[@name='" + settingNameValid + "']"); if (SettingNode == null) { //Agregar el nodo SettingNode = ConfigDocument.CreateElement("Setting"); Attribute = ConfigDocument.CreateAttribute("name"); Attribute.Value = settingNameValid; SettingNode.Attributes.Append(Attribute); Attribute = ConfigDocument.CreateAttribute("value"); Attribute.Value = settingValue; SettingNode.Attributes.Append(Attribute); SectionNode.AppendChild(SettingNode); } System.Xml.XmlAttribute SettingAttribute = SettingNode.Attributes["value"]; if (SettingAttribute != null) { SettingAttribute.Value = settingValue; } ConfigDocument.Save(ConfigFileName); } }
/// <summary> /// Generates an Xml element for this rule /// </summary> /// <param name="doc">The parent Xml document</param> /// <returns>XmlNode representing this rule</returns> public override System.Xml.XmlNode Serialize(System.Xml.XmlDocument doc) { if (assignValue.ToString().Length > 0 && string.IsNullOrEmpty(assignValue.ToString().Trim())) { assignValue = " "; } if (UseElse && elseValue != null && elseValue.ToString().Length > 0 && string.IsNullOrEmpty(elseValue.ToString().Trim())) { elseValue = " "; } string xmlString = "<friendlyRule>" + friendlyRule.Replace("&", "&").Replace("<", "<").Replace(">", ">") + "</friendlyRule>" + "<destinationColumnName>" + destinationColumnName + "</destinationColumnName>" + "<destinationColumnType>" + destinationColumnType + "</destinationColumnType>"; if (DestinationColumnType == "System.Decimal" && assignValue is decimal) { decimal d = (decimal)assignValue; xmlString += "<assignValue>" + d.ToString(CultureInfo.InvariantCulture).Replace("&", "&").Replace("<", "<").Replace(">", ">") + "</assignValue>"; } else { xmlString += "<assignValue>" + assignValue.ToString().Replace("&", "&").Replace("<", "<").Replace(">", ">") + "</assignValue>"; } xmlString += "<useElse>" + UseElse + "</useElse>"; if (elseValue != null) { //xmlString = xmlString + "<elseValue>" + elseValue.ToString().Replace("&", "&").Replace("<", "<").Replace(">", ">") + "</elseValue>"; if (DestinationColumnType == "System.Decimal" && elseValue is decimal) { decimal d = (decimal)elseValue; xmlString += "<elseValue>" + d.ToString(CultureInfo.InvariantCulture).Replace("&", "&").Replace("<", "<").Replace(">", ">") + "</elseValue>"; } else { xmlString += "<elseValue>" + elseValue.ToString().Replace("&", "&").Replace("<", "<").Replace(">", ">") + "</elseValue>"; } } System.Xml.XmlElement element = doc.CreateElement("rule"); element.InnerXml = xmlString; element.AppendChild(DataFilters.Serialize(doc)); System.Xml.XmlAttribute order = doc.CreateAttribute("order"); System.Xml.XmlAttribute type = doc.CreateAttribute("ruleType"); type.Value = "EpiDashboard.Rules.Rule_ConditionalAssign"; element.Attributes.Append(type); return(element); }
public override System.Xml.XmlNode SerializeToXML(System.Xml.XmlDocument xdoc) { XmlNode xn = base.SerializeToXML(xdoc); xn.Attributes.Append(xdoc.CreateAttribute("NewWidth")).Value = mNewWidth.ToString(nfi); xn.Attributes.Append(xdoc.CreateAttribute("NewHeight")).Value = mNewHeight.ToString(nfi); xn.Attributes.Append(xdoc.CreateAttribute("LimitWidth")).Value = mLimitWidth.ToString(); xn.Attributes.Append(xdoc.CreateAttribute("LimitHeight")).Value = mLimitHeight.ToString(); return(xn); }
public void WriteTo(System.Xml.XmlDocument doc, string group) { var provider = doc.CreateElement("providers"); doc.DocumentElement.AppendChild(provider); if (!String.IsNullOrEmpty(this._ProviderType)) { var providerType = doc.CreateAttribute("providerType"); providerType.Value = this._ProviderType; provider.Attributes.Append(providerType); } if (String.IsNullOrEmpty(group) == false) { var groupAttr = doc.CreateAttribute("group"); groupAttr.Value = group; provider.Attributes.Append(groupAttr); } for (int i = 0; i < this._KeyIndex.Count; i++) { Provider pro = (Provider)this._Providers[this._KeyIndex[i]]; var add = doc.CreateElement("add"); var name = doc.CreateAttribute("name"); name.Value = pro.Name; add.Attributes.Append(name); var type = doc.CreateAttribute("type"); type.Value = pro.Type; add.Attributes.Append(type); for (int a = 0; a < pro.Attributes.Count; a++) { string str = pro.Attributes[a]; if (!String.IsNullOrEmpty(str)) { if (str.IndexOf('\n') > -1) { var node = doc.CreateElement(pro.Attributes.GetKey(a)); node.AppendChild(doc.CreateCDataSection(str)); add.AppendChild(node); } else { var att = doc.CreateAttribute(pro.Attributes.GetKey(a)); att.Value = str; add.Attributes.Append(att); } } } provider.AppendChild(add); } }
public void Save() { try { if (File.Exists(DB)) { core.backupData(DB); if (!File.Exists(config.tempName(DB))) { core.Log("Unable to create backup file for " + owner.Name); } } System.Xml.XmlDocument data = new System.Xml.XmlDocument(); System.Xml.XmlNode xmlnode = data.CreateElement("database"); lock (Content) { foreach (Item key in Content) { XmlAttribute name = data.CreateAttribute("name"); name.Value = key.name; XmlAttribute url = data.CreateAttribute("url"); url.Value = key.URL; XmlAttribute disabled = data.CreateAttribute("disb"); disabled.Value = key.disabled.ToString(); XmlAttribute template = data.CreateAttribute("template"); template.Value = key.template; XmlAttribute scan = data.CreateAttribute("so"); template.Value = key.ScannerOnly.ToString(); System.Xml.XmlNode db = data.CreateElement("data"); db.Attributes.Append(name); db.Attributes.Append(url); db.Attributes.Append(disabled); db.Attributes.Append(template); db.Attributes.Append(scan); xmlnode.AppendChild(db); } } data.AppendChild(xmlnode); data.Save(DB); if (System.IO.File.Exists(config.tempName(DB))) { System.IO.File.Delete(config.tempName(DB)); } } catch (Exception fail) { RSS.m.handleException(fail); } }
public void Upgrade(string projectPath, string userSettingsPath, ref System.Xml.XmlDocument projectDocument, ref System.Xml.XmlDocument userSettingsDocument, ref System.Xml.XmlNamespaceManager nsm) { //Add DataTypeReferencedTableMappingSchemaName to each Parameter. foreach (XmlAttribute node in projectDocument.SelectNodes("//*/@DataTypeReferencedTableMappingName", nsm)) { XmlAttribute tableSchemaName = (XmlAttribute)node.SelectSingleNode("//P:TableMapping[@TableName='{0}']/@SchemaName".FormatString(node.Value), nsm); XmlAttribute dataTypeReferencedTableMappingSchemaName = projectDocument.CreateAttribute("DataTypeReferencedTableMappingSchemaName"); dataTypeReferencedTableMappingSchemaName.Value = tableSchemaName.Value; node.OwnerElement.Attributes.Append(dataTypeReferencedTableMappingSchemaName); } //Add ParentTableMappingSchemaName and ReferencedTableMappingSchemaName to each Foreign Key Mapping. foreach (XmlElement node in projectDocument.SelectNodes("//P:ForeignKeyMapping", nsm)) { XmlAttribute parentTableSchemaName = (XmlAttribute)projectDocument.SelectSingleNode("//P:TableMapping[@TableName='{0}']/@SchemaName".FormatString(node.GetAttribute("ParentTableMappingName")), nsm); XmlAttribute referencedTableSchemaName = (XmlAttribute)projectDocument.SelectSingleNode("//P:TableMapping[@TableName='{0}']/@SchemaName".FormatString(node.GetAttribute("ReferencedTableMappingName")), nsm); XmlAttribute parentTableMappingSchemaName = projectDocument.CreateAttribute("ParentTableMappingSchemaName"); XmlAttribute referencedTableMappingSchemaName = projectDocument.CreateAttribute("ReferencedTableMappingSchemaName"); parentTableMappingSchemaName.Value = parentTableSchemaName.Value; referencedTableMappingSchemaName.Value = referencedTableSchemaName.Value; node.Attributes.Append(parentTableMappingSchemaName); node.Attributes.Append(referencedTableMappingSchemaName); } //Add ReferencedTableMappingSchemaName to each Enumeration Mapping. //Rename ReferencedTableName to ReferencedTableMappingName for each Enumeration Mapping foreach (XmlAttribute node in projectDocument.SelectNodes("//P:EnumerationMapping/@ReferencedTableName", nsm)) { XmlAttribute tableSchemaName = (XmlAttribute)projectDocument.SelectSingleNode("//P:TableMapping[@TableName='{0}']/@SchemaName".FormatString(node.Value), nsm); XmlAttribute tableMappingSchemaName = projectDocument.CreateAttribute("ReferencedTableMappingSchemaName"); XmlAttribute tableMappingName = projectDocument.CreateAttribute("ReferencedTableMappingName"); tableMappingSchemaName.Value = tableSchemaName.Value; tableMappingName.Value = node.Value; node.OwnerElement.Attributes.Append(tableMappingSchemaName); node.OwnerElement.Attributes.Append(tableMappingName); node.OwnerElement.Attributes.Remove(node); } //Remove Template.Name attribute. foreach (XmlAttribute node in projectDocument.SelectNodes("//P:Template/@Name", nsm)) { node.OwnerElement.Attributes.Remove(node); } }
//save into package public void SaveToXML(System.Xml.XmlDocument doc, IDTSInfoEvents infoEvents) { XmlElement elementRoot; XmlNode propertyNode; elementRoot = doc.CreateElement(string.Empty, "DtParameters", string.Empty); if (DtParameters != null) { if (DtParameters.Rows.Count > 0) { // foreach (DataRow row in DtParameters.Rows) { propertyNode = doc.CreateNode(XmlNodeType.Element, "Parameter", string.Empty); propertyNode.InnerText = row["ParameterValue"].ToString(); XmlAttribute attrParameterName = doc.CreateAttribute("ParameterName"); attrParameterName.Value = row["ParameterName"].ToString(); propertyNode.Attributes.Append(attrParameterName); XmlAttribute attrRequired = doc.CreateAttribute("Required"); attrRequired.Value = row["Required"].ToString(); propertyNode.Attributes.Append(attrRequired); elementRoot.AppendChild(propertyNode); } } } propertyNode = doc.CreateNode(XmlNodeType.Element, "Server", string.Empty); propertyNode.InnerText = Server; elementRoot.AppendChild(propertyNode); propertyNode = doc.CreateNode(XmlNodeType.Element, "SelectedReport", string.Empty); propertyNode.InnerText = SelectedReport; elementRoot.AppendChild(propertyNode); propertyNode = doc.CreateNode(XmlNodeType.Element, "FileName", string.Empty); propertyNode.InnerText = FileName; elementRoot.AppendChild(propertyNode); propertyNode = doc.CreateNode(XmlNodeType.Element, "FileFormat", string.Empty); propertyNode.InnerText = FileFormat; elementRoot.AppendChild(propertyNode); doc.AppendChild(elementRoot); }
public void AddAttribute(System.Xml.XmlNode node, String label, String value) { System.Xml.XmlAttribute attrib; attrib = doc.CreateAttribute(label); attrib.Value = value; node.Attributes.Append(attrib); }
public void addEnanchedInfosTag(string name, string innerXml) { System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); if (EnanchedInfos != null) { doc.LoadXml(EnanchedInfos); } else { doc.LoadXml("<det></det>"); } XmlElement el = doc.CreateElement("d"); XmlAttribute at = doc.CreateAttribute("n"); at.Value = name; el.Attributes.Append(at); string parsingText = innerXml.Replace(".", "").Replace("/", "").Replace(";", "").Replace("\\", ""); try { el.InnerXml = parsingText; } catch (Exception ex) { el.InnerXml = "Errore non gestito"; } finally { doc.FirstChild.AppendChild(el); EnanchedInfos = doc.DocumentElement.OuterXml; } }
public override System.Xml.XmlNode SerializeToXML(System.Xml.XmlDocument xdoc) { XmlNode xn = base.SerializeToXML(xdoc); xn.Attributes.Append(xdoc.CreateAttribute("Saturation")).Value = mSaturation.ToString(nfi); return(xn); }
void Save() { var doc = new System.Xml.XmlDocument(); var xmlDeclaration = doc.CreateXmlDeclaration("1.0", "UTF-8", null); var root = doc.DocumentElement; doc.InsertBefore(xmlDeclaration, root); var records = doc.CreateElement("records"); doc.AppendChild(records); var tables = doc.CreateElement(string.Empty, "tables", string.Empty); var singleRecords = doc.CreateElement(string.Empty, "srec", string.Empty); var teamRecords = doc.CreateElement(string.Empty, "trec", string.Empty); records.AppendChild(singleRecords); records.AppendChild(teamRecords); records.AppendChild(tables); // single records: foreach (var s in this.mSingleStorage) { var r = doc.CreateElement(string.Empty, "record", string.Empty); var dsvId = doc.CreateAttribute("id"); dsvId.Value = s.SwimmerId; r.Attributes.Append(dsvId); } }
public void getIML(System.Xml.XmlDocument doc, System.Xml.XmlNode parentElem) { if (sourcePath == "#Crow.DefaultItem.template") { return; } XmlElement xe = doc.CreateElement("ItemTemplate"); XmlAttribute xa = null; if (string.IsNullOrEmpty(sourcePath)) { //inline item template using (GraphicObject go = this.CreateInstance()) go.getIML(doc, xe); } else { xa = doc.CreateAttribute("Path"); xa.Value = sourcePath; xe.Attributes.Append(xa); } if (strDataType != "default") { xa = doc.CreateAttribute("DataType"); xa.Value = strDataType; xe.Attributes.Append(xa); if (dataTest != "TypeOf") { xa = doc.CreateAttribute("DataTest"); xa.Value = dataTest; xe.Attributes.Append(xa); } } if (!string.IsNullOrEmpty(fetchMethodName)) { xa = doc.CreateAttribute("Data"); xa.Value = fetchMethodName; xe.Attributes.Append(xa); } parentElem.AppendChild(xe); }
/// <summary> /// Saves settings to XML. /// </summary> /// <param name="doc">The doc.</param> /// <param name="infoEvents">The info events.</param> void IDTSComponentPersist.SaveToXML(System.Xml.XmlDocument doc, IDTSInfoEvents infoEvents) { try { //create node in the package xml document XmlElement taskElement = doc.CreateElement(string.Empty, "PGPTask", string.Empty); XmlAttribute sourceAttr = doc.CreateAttribute(string.Empty, CONSTANTS.PGPSOURCEFILE, string.Empty); sourceAttr.Value = this.sourceFile; taskElement.Attributes.Append(sourceAttr); XmlAttribute targetAttr = doc.CreateAttribute(string.Empty, CONSTANTS.PGPTARGETFILE, string.Empty); targetAttr.Value = this.targetFile; taskElement.Attributes.Append(targetAttr); XmlAttribute publicAttr = doc.CreateAttribute(string.Empty, CONSTANTS.PGPPUBLICKEY, string.Empty); publicAttr.Value = this.publicKey; taskElement.Attributes.Append(publicAttr); XmlAttribute privateAttr = doc.CreateAttribute(string.Empty, CONSTANTS.PGPPRIVATEKEY, string.Empty); privateAttr.Value = this.privateKey; taskElement.Attributes.Append(privateAttr); XmlAttribute passAttr = doc.CreateAttribute(string.Empty, CONSTANTS.PGPPASSPHRASE, string.Empty); passAttr.Value = this.passPhrase; taskElement.Attributes.Append(passAttr); XmlAttribute fileActionAttr = doc.CreateAttribute(string.Empty, CONSTANTS.PGPFILEACTION, string.Empty); fileActionAttr.Value = this.fileAction.ToString(); taskElement.Attributes.Append(fileActionAttr); XmlAttribute overwriteRemoteAttr = doc.CreateAttribute(string.Empty, CONSTANTS.PGPOVERWRITETARGET, string.Empty); overwriteRemoteAttr.Value = this.overwriteTarget.ToString(); taskElement.Attributes.Append(overwriteRemoteAttr); XmlAttribute removeAttr = doc.CreateAttribute(string.Empty, CONSTANTS.PGPREMOVESOURCE, string.Empty); removeAttr.Value = this.removeSource.ToString(); taskElement.Attributes.Append(removeAttr); XmlAttribute armoredAttr = doc.CreateAttribute(string.Empty, CONSTANTS.PGPARMORED, string.Empty); armoredAttr.Value = this.isArmored.ToString(); taskElement.Attributes.Append(armoredAttr); //add the new element to the package document doc.AppendChild(taskElement); } catch (Exception ex) { infoEvents.FireError(0, "Save To XML: ", ex.Message + ex.StackTrace, "", 0); } }
public static void SetRootAttribute(System.Xml.XmlDocument xmlDocument, string attributeName, string attributeValue) { if (xmlDocument.DocumentElement.Attributes[attributeName] == null) { xmlDocument.DocumentElement.Attributes.Append(xmlDocument.CreateAttribute(attributeName)); } xmlDocument.DocumentElement.Attributes[attributeName].Value = attributeValue; }
public override System.Xml.XmlNode SerializeToXML(System.Xml.XmlDocument xdoc) { XmlNode xn = base.SerializeToXML(xdoc); xn.Attributes.Append(xdoc.CreateAttribute("Edge")).Value = mEdge.ToString(nfi); xn.Attributes.Append(xdoc.CreateAttribute("Softness")).Value = mSoftness.ToString(nfi); xn.AppendChild(mDarkTone.SerializeToXML(xdoc)).Attributes.Append(xdoc.CreateAttribute("Name")).Value = "DarkTone"; xn.AppendChild(mLightTone.SerializeToXML(xdoc)).Attributes.Append(xdoc.CreateAttribute("Name")).Value = "LightTone"; xn.Attributes.Append(xdoc.CreateAttribute("AutoDarkTone")).Value = mAutoDarkTone.ToString(); xn.Attributes.Append(xdoc.CreateAttribute("AutoLightTone")).Value = mAutoLightTone.ToString(); xn.Attributes.Append(xdoc.CreateAttribute("AutoDarkRadius")).Value = mAutoDarkRadius.ToString(nfi); xn.Attributes.Append(xdoc.CreateAttribute("AutoLightRadius")).Value = mAutoLightRadius.ToString(nfi); xn.AppendChild(mAutoDarkCenter.SerializeToXML(xdoc)).Attributes.Append(xdoc.CreateAttribute("Name")).Value = "AutoDarkCenter"; xn.AppendChild(mAutoLightCenter.SerializeToXML(xdoc)).Attributes.Append(xdoc.CreateAttribute("Name")).Value = "AutoLightCenter"; return(xn); }
protected override void WriteItemAttributes(System.Xml.XmlDocument doc, System.Xml.XmlElement item) { base.WriteItemAttributes(doc, item); XmlAttribute parentbranchid = doc.CreateAttribute("ParentBranchID"); parentbranchid.Value = this.ParentBranchID.ToString(); item.Attributes.Append(parentbranchid); }
/// <summary> /// Generates an Xml element for this rule /// </summary> /// <param name="doc">The parent Xml document</param> /// <returns>XmlNode representing this rule</returns> public override System.Xml.XmlNode Serialize(System.Xml.XmlDocument doc) { string xmlString = "<friendlyRule>" + friendlyRule + "</friendlyRule>" + "<expression>" + expression + "</expression>" + "<destinationColumnName>" + destinationColumnName + "</destinationColumnName>" + "<destinationColumnType>" + destinationColumnType + "</destinationColumnType>"; System.Xml.XmlElement element = doc.CreateElement("rule"); element.InnerXml = xmlString; System.Xml.XmlAttribute order = doc.CreateAttribute("order"); System.Xml.XmlAttribute type = doc.CreateAttribute("ruleType"); type.Value = "EpiDashboard.Rules.Rule_ExpressionAssign"; element.Attributes.Append(type); return(element); }
/// ----------------------------------------------------------------------------- /// <summary> /// Constructor to call when creating a Root Node /// </summary> /// <param name="strNamespace">Namespace of node hierarchy</param> /// <remarks> /// </remarks> /// <history> /// [Jon Henning] 12/22/2004 Created /// </history> /// ----------------------------------------------------------------------------- public XmlCollectionBase(string strNamespace) { InnerXMLDoc = new System.Xml.XmlDocument(); InnerXMLNode = InnerXMLDoc.CreateNode(XmlNodeType.Element, "root", ""); System.Xml.XmlAttribute objAttr = InnerXMLDoc.CreateAttribute("id"); objAttr.Value = strNamespace; InnerXMLNode.Attributes.Append(objAttr); InnerXMLDoc.AppendChild(InnerXMLNode); }
public XmlCollectionBase(string strNamespace, DotNetNuke.UI.WebControls.DNNTree objTreeControl) { m_objTree = objTreeControl; InnerXMLDoc = new System.Xml.XmlDocument(); InnerXMLNode = InnerXMLDoc.CreateNode(XmlNodeType.Element, "root", ""); System.Xml.XmlAttribute objAttr = InnerXMLDoc.CreateAttribute("id"); objAttr.Value = strNamespace; InnerXMLNode.Attributes.Append(objAttr); InnerXMLDoc.AppendChild(InnerXMLNode); }
/// <summary> /// Generates an Xml element for this rule /// </summary> /// <param name="doc">The parent Xml document</param> /// <returns>XmlNode representing this rule</returns> public override System.Xml.XmlNode Serialize(System.Xml.XmlDocument doc) { string xmlString = "<friendlyRule>" + friendlyRule + "</friendlyRule>" + "<sourceColumnName>" + sourceColumnName + "</sourceColumnName>" + "<destinationColumnName>" + destinationColumnName + "</destinationColumnName>" + "<destinationColumnType>" + destinationColumnType + "</destinationColumnType>" + "<formatString>" + formatString + "</formatString>" + "<formatType>" + ((int)formatType).ToString() + "</formatType>"; System.Xml.XmlElement element = doc.CreateElement("rule"); element.InnerXml = xmlString; System.Xml.XmlAttribute order = doc.CreateAttribute("order"); System.Xml.XmlAttribute type = doc.CreateAttribute("ruleType"); type.Value = "Epi.WPF.Dashboard.Rules.Rule_Format"; element.Attributes.Append(type); return(element); }
public override System.Xml.XmlNode SerializeToXML(System.Xml.XmlDocument xdoc) { XmlNode xn = base.SerializeToXML(xdoc); xn.Attributes.Append(xdoc.CreateAttribute("Angle")).Value = mAngle.ToString(nfi); xn.Attributes.Append(xdoc.CreateAttribute("CropWidth")).Value = mCropWidth.ToString(nfi); xn.Attributes.Append(xdoc.CreateAttribute("CropHeight")).Value = mCropHeight.ToString(nfi); xn.Attributes.Append(xdoc.CreateAttribute("AspectRatio")).Value = mAspectRatio.ToString(nfi); xn.Attributes.Append(xdoc.CreateAttribute("AspectRatioPreset")).Value = mAspectRatioPreset.ToString(nfi); xn.Attributes.Append(xdoc.CreateAttribute("AspectRatioCustom")).Value = mAspectRatioCustom.ToString(); xn.Attributes.Append(xdoc.CreateAttribute("Mode")).Value = ((int)mMode).ToString(); xn.AppendChild(mCenter.SerializeToXML(xdoc)).Attributes.Append(xdoc.CreateAttribute("Name")).Value = "Center"; return(xn); }
/// <summary> /// 清理组装xml,有点low /// </summary> /// <param name="s"></param> /// <returns></returns> public virtual string CleanXml(string s) { System.Xml.XmlDocument xml = new System.Xml.XmlDocument(); xml.LoadXml(s.Replace("<?xml version=\"1.0\"?>", "").Replace("xmlns=\"\"", "").Trim()); System.Xml.XmlNode root = xml.DocumentElement; XmlAttribute ra = xml.CreateAttribute("ITSVersion"); ra.Value = "XML_1.0"; root.Attributes.Append(ra); var result = new StringBuilder(xml.InnerXml).ToString(); return(result.Replace("<?xml version=\"1.0\"?>", "").Replace("xsi_type", "xsi:type").Trim()); }
protected void adminSaveBtn_Click(object sender, EventArgs e) { //XML Data Source : AdminPost.xml XmlDocument xmldoc = XmlDataSource1.GetXmlDocument(); //Get the XML Data Latest Post Record XmlNodeList xnlist = xmldoc.SelectNodes("//user[last()]"); //Get the Latest Record ID String olduserID = xnlist[0].Attributes[0].Value.ToString(); int user = int.Parse(olduserID.Substring(1)); user++; String newUserID = "U" + user; XmlDocument doc = new System.Xml.XmlDocument(); doc.Load(Server.MapPath(AdminXmlFilePath)); XmlNode adminNode = doc.CreateElement("user"); XmlAttribute adminAttribute = doc.CreateAttribute("id"); adminAttribute.Value = newUserID; adminNode.Attributes.Append(adminAttribute); doc.DocumentElement.AppendChild(adminNode); XmlNode emailNode = doc.CreateElement("email"); emailNode.AppendChild(doc.CreateTextNode(this.adminEmail.Text)); adminNode.AppendChild(emailNode); XmlNode passNode = doc.CreateElement("pass"); passNode.AppendChild(doc.CreateTextNode(this.adminPassword.Text)); adminNode.AppendChild(passNode); XmlNode nameNode = doc.CreateElement("name"); nameNode.AppendChild(doc.CreateTextNode(this.adminName.Text)); adminNode.AppendChild(nameNode); XmlNode numberNode = doc.CreateElement("numberPost"); numberNode.AppendChild(doc.CreateTextNode("0")); adminNode.AppendChild(numberNode); doc.Save(Server.MapPath(AdminXmlFilePath)); Response.Redirect("AdminSignIn.aspx"); }
private bool setASPNETProcessInfinite() { const string processModelNode = "/configuration/system.web/processModel"; const string infinite = "Infinite"; const string responseDeadlockInterval = "responseDeadlockInterval"; try { string sConfigFile = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory() + "Config\\machine.config"; System.Xml.XmlNode node = null; System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); xmlDoc.PreserveWhitespace = true; xmlDoc.Load(sConfigFile); node = xmlDoc.SelectSingleNode(processModelNode); if (node == null) { // The processModel attribute doesn't exist, which basically // means that they've either heavily modified their ASP.NET // configuration or there is a very bad error with their system. return(false); } // Check node value System.Xml.XmlAttribute attrDeadlockInterval = node.Attributes[responseDeadlockInterval]; if (attrDeadlockInterval != null) { attrDeadlockInterval.InnerText = infinite; } else { node.Attributes.Append(xmlDoc.CreateAttribute(String.Empty, responseDeadlockInterval, infinite)); } // Overwrite the original file. xmlDoc.Save(sConfigFile); } catch (System.Exception) { // If an error occurred (such as the file being secured, etc.), just // return false. return(false); } return(true); }