}//public static void WriteXml ///<summary>Write XMLStylesheet.</summary> /// <param name="exceptionMessage">Exception Message.</param> /// <param name="filenameXml">Filename XML.</param> /// <param name="filenameStylesheet">Filename Stylesheet (XSLT).</param> public static void WriteXmlStylesheet ( ref string exceptionMessage, ref string filenameXml, ref string filenameStylesheet ) { string xmlProcessingInstructionText = null; HttpContext httpContextCurrent = HttpContext.Current; XmlNode xmlNodeDocumentType = null; XmlNode xmlNodeRoot = null; XmlDocument xmlDocument = null; XmlProcessingInstruction xmlProcessingInstruction = null; if ( string.IsNullOrEmpty( filenameStylesheet ) == true ) { return; } try { xmlDocument = new XmlDocument(); xmlDocument.Load( filenameXml ); xmlProcessingInstructionText = "type='text/xsl' href='" + filenameStylesheet + "'"; xmlProcessingInstruction = xmlDocument.CreateProcessingInstruction ( "xml-stylesheet", xmlProcessingInstructionText ); xmlNodeDocumentType = xmlDocument.DocumentType; xmlNodeRoot = xmlDocument.DocumentElement; xmlDocument.InsertBefore(xmlProcessingInstruction, xmlNodeRoot); xmlDocument.Save( filenameXml ); }//try catch (SecurityException exception) { exceptionMessage = exception.Message; System.Console.WriteLine( "SecurityException: {0}", exception.Message ); }//catch (SecurityException exception) catch (XmlException exception) { exceptionMessage = exception.Message; System.Console.WriteLine( "XmlException: {0}", exception.Message ); }//catch (XmlException exception) catch (SystemException exception) { exceptionMessage = exception.Message; System.Console.WriteLine( "SystemException: {0}", exception.Message ); }//catch (SystemException exception) catch (Exception exception) { exceptionMessage = exception.Message; System.Console.WriteLine( "Exception: {0}", exception.Message ); }//catch (Exception exception) #if (DEBUG) if ( httpContextCurrent != null && exceptionMessage != null ) { httpContextCurrent.Response.Write( "Exception: " + exceptionMessage ); }//if ( httpContextCurrent != null && exceptionMessage != null ) #endif }//public static void WriteXmlStylesheet()
public override XmlNode AppendXmlNode(XmlNode parent) { XmlDocument xmlDoc = (XmlDocument)parent; XmlProcessingInstruction instruction = xmlDoc.CreateProcessingInstruction("xml", "version=\"1.0\""); xmlDoc.AppendChild(instruction); instruction = xmlDoc.CreateProcessingInstruction("mso-application", "progid=\"Excel.Sheet\""); xmlDoc.AppendChild(instruction); XmlElement node = (XmlElement)xmlDoc.CreateElement("Workbook", Namespaces.spreadsheet); node.SetAttribute("xmlns:o", Namespaces.o); node.SetAttribute("xmlns:x", Namespaces.x); node.SetAttribute("xmlns:ss", Namespaces.ss); node.SetAttribute("xmlns:html", Namespaces.html); parent.AppendChild(node); DocumentProperties.AppendXmlNode(node); if (_ExcelWorkbook != null) { _ExcelWorkbook.AppendXmlNode(node); } Styles.AppendXmlNode(node); Names.AppendXmlNode(node); Worksheets.AppendXmlNode(node); return(node); }
public void AddPI(object doc, string data) { XmlDocument xmlDocument = InMetaXmlUtils.TryGetXmlDocument(doc); if (xmlDocument != null) { XmlNode firstChild = xmlDocument.FirstChild; if (firstChild != null && (firstChild.NodeType == XmlNodeType.ProcessingInstruction && firstChild.Name == "xml")) { xmlDocument.RemoveChild(firstChild); } XmlProcessingInstruction processingInstruction = xmlDocument.CreateProcessingInstruction("xml", data); xmlDocument.InsertBefore((XmlNode)processingInstruction, xmlDocument.FirstChild); } else { object firstChild = InMetaXmlUtils.InteropGetFirstChild(doc); if (firstChild != null && (InMetaXmlUtils.InteropGetNodeType(firstChild) == 7 && InMetaXmlUtils.InteropGetNodeName(firstChild) == "xml")) { InMetaXmlUtils.InteropRemoveChild(doc, firstChild); } object processingInstruction = InMetaXmlUtils.InteropCreateProcessingInstruction(doc, "xml", data); InMetaXmlUtils.InteropInsertBefore(doc, processingInstruction, InMetaXmlUtils.InteropGetFirstChild(doc)); } }
private void CreateDataSource() { Exception exception_ex = new Exception(); XmlDocument data = null; XmlNode declaration = null; XmlProcessingInstruction style = null; XmlElement root = null; XmlAttribute @created = null; try { data = new XmlDocument(); declaration = data.CreateNode(XmlNodeType.XmlDeclaration, "", ""); data.AppendChild(declaration); style = data.CreateProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"data.xsl\""); data.AppendChild(style); root = data.CreateElement("data"); @created = data.CreateAttribute("created"); @created.Value = DateTime.Now.ToString(); root.Attributes.Append(@created); data.AppendChild(root); data.Save(this.location); } catch (Exception ex) { exception_ex = ex; } }
private static void CreateDebugLog() { XmlDocument doc = new XmlDocument(); FileStream reportFile = new FileStream(debugLogFullPath, FileMode.Create); XmlNode docNode = doc.CreateXmlDeclaration("1.0", "UTF-8", null); doc.AppendChild(docNode); XmlProcessingInstruction xProcess = doc.CreateProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"Template\\Details.xsl\""); doc.AppendChild(xProcess); XmlNode testDetails = doc.CreateElement("testdetails"); doc.AppendChild(testDetails); XmlNode testNode = doc.CreateElement("test"); AddAttributes(testNode, doc); testDetails.AppendChild(testNode); doc.Save(reportFile); reportFile.Close(); }
static void access() { XmlDocument xDoc = new XmlDocument(); FileStream myFile = new FileStream("../../try1.xml", FileMode.Open); xDoc.Load(myFile); Console.Write("Access to XmlElement, nodetype: " + xDoc.DocumentElement.NodeType + "\n\n"); //++++++++++++++++ XmlNodeList second = xDoc.SelectNodes("descendant::row[LineID=5]"); Console.Write("Access to XmlText, nodetype: " + second[0].ChildNodes[1].ChildNodes[0].InnerText + "\n\n"); //++++++++++++++++ foreach (XmlComment commentNode in xDoc.SelectNodes("//comment()")) { Console.Write("Access to comment: " + commentNode.Value); } //++++++++++++++++++ XmlProcessingInstruction procIns = (XmlProcessingInstruction)xDoc.DocumentElement.ChildNodes[0]; Console.Write("\n\nAccess to instruction: " + procIns.Name); //++++++++++++++++ second = xDoc.SelectNodes("descendant::row[LineID<5]"); for (int i = 0; i < second.Count; i++) { Console.Write("\nAccess to attribute: " + second[i].ChildNodes[1].ChildNodes[0].Value + "\r\n"); } myFile.Close(); }
public static void ToGraphML(Node[] nodes, bool direction, string path) { XmlDocument doc = new XmlDocument(); XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", "UTF-8", null); var root = doc.CreateElement("graph"); var attr = doc.CreateAttribute("id"); attr.InnerText = "G"; root.Attributes.Append(attr); var dir = doc.CreateAttribute("edgedefault"); dir.InnerText = direction ? "directed" : "undirected"; root.Attributes.Append(dir); doc.AppendChild(declaration); doc.AppendChild(root); XmlProcessingInstruction pi = doc.CreateProcessingInstruction("graphml", "xmlns=\"http://graphml.graphdrawing.org/xmlns \" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance \" xsi: schemaLocation = \"http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd \""); doc.InsertBefore(pi, doc.ChildNodes[1]); for (int i = 0; i < nodes.Length; i++) { XmlNode Node = doc.CreateElement("node"); var attribute = doc.CreateAttribute("id"); attribute.InnerText = "n" + i.ToString(); Node.Attributes.Append(attribute); root.AppendChild(Node); } doc.Save(path); }
public StyleSheet(XmlProcessingInstruction pi) : this(string.Empty) { Match match = _reParser.Match(pi.Data); while (match.Success) { string name = match.Groups["name"].Value; string val = match.Groups["value"].Value; switch (name) { case "href": _href = val; break; case "type": _type = val; break; case "title": _title = val; break; case "media": _media = new MediaList(val); break; } match = match.NextMatch(); } _ownerNode = pi; }
private void Save_Parameter() { XmlDocument oparamsxml = new XmlDocument(); XmlProcessingInstruction _xml_header = oparamsxml.CreateProcessingInstruction("xml", "version='1.0' encoding='UTF-8'"); oparamsxml.InsertBefore(_xml_header, oparamsxml.ChildNodes.Item(0)); XmlNode parameters = oparamsxml.CreateNode(XmlNodeType.Element, "Parameters", ""); XmlNode path = oparamsxml.CreateNode(XmlNodeType.Element, "Path", ""); XmlAttribute attribute = oparamsxml.CreateAttribute("monitored"); attribute.Value = this.textBox1.Text.Trim(); path.Attributes.Append(attribute); attribute = oparamsxml.CreateAttribute("destination"); attribute.Value = this.textBox2.Text.Trim(); path.Attributes.Append(attribute); parameters.AppendChild(path); oparamsxml.AppendChild(parameters); oparamsxml.Save(this.HomeDir + "\\config\\params.xml"); }
protected string GetXml() #endif { var doc = new XmlDocument(); XmlProcessingInstruction xpi = doc.CreateProcessingInstruction("xml", "version='1.0' encoding='UTF-8'"); doc.AppendChild(xpi); XmlElement root = doc.CreateElement("WIRECARD_BXML"); root.SetAttribute("xmlns:xsi", "http://www.w3.org/1999/XMLSchema-instance"); doc.AppendChild(root); XmlElement request = doc.CreateElement("W_REQUEST"); root.AppendChild(request); foreach (Job job in _jobs) { XmlElement node = job.GetXml(doc); request.AppendChild(node); } return(doc.OuterXml); }
private void pLoteRPS(XmlElement EnviarLoteRpsEnvio, string nrLote, string cnpj, string inscricaoMunicipal, string qtdeRPS) { XmlProcessingInstruction pi = docXml.CreateProcessingInstruction("xml", "version=\"1.0\" encoding=\"ISO-8859-1\" standalone=\"no\""); docXml.InsertBefore(pi, EnviarLoteRpsEnvio); XmlElement LoteRps = docXml.CreateElement("LoteRps"); EnviarLoteRpsEnvio.AppendChild(LoteRps); XmlElement Cnpj = docXml.CreateElement("Cnpj"); Cnpj.InnerText = cnpj; LoteRps.AppendChild(Cnpj); XmlElement NumeroLote = docXml.CreateElement("NumeroLote"); NumeroLote.InnerText = nrLote; LoteRps.AppendChild(NumeroLote); XmlElement InscricaoMunicipal = docXml.CreateElement("InscricaoMunicipal"); InscricaoMunicipal.InnerText = inscricaoMunicipal; LoteRps.AppendChild(InscricaoMunicipal); XmlElement QuantidadeRps = docXml.CreateElement("QuantidadeRps"); QuantidadeRps.InnerText = qtdeRPS; LoteRps.AppendChild(QuantidadeRps); pRps(LoteRps); }
public override void WriteProcessingInstruction(string name, string value) { XmlProcessingInstruction pi = current.OwnerDocument.CreateProcessingInstruction(name, value); current.AppendChild(pi); document.AppendChild(current, pi); }
//--------------------------------------------------------------------------- static XmlDocument DataSet2XmlDocument(DataSet ds, string XSLFileName) { XmlDocument doc = new XmlDocument(); XmlNode node = doc.CreateXmlDeclaration("1.0", "windows-1251", null); doc.AppendChild(node); if (XSLFileName != null && XSLFileName != string.Empty) { XmlProcessingInstruction pi = doc.CreateProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"" + XSLFileName + "\""); doc.AppendChild(pi); } node = doc.CreateElement(ds.DataSetName); doc.AppendChild(node); DataTable tbl; for (int i = 0; i < ds.Tables.Count; ++i) { tbl = ds.Tables[i]; doc.DocumentElement.AppendChild(Table2XmlNode(doc, tbl)); } return(doc); }
public StyleSheet(XmlProcessingInstruction pi) : this(String.Empty) { Regex re = new Regex(@"(?<name>[a-z]+)=[""'](?<value>[^""']*)[""']"); Match match = re.Match(pi.Data); while (match.Success) { string name = match.Groups["name"].Value; string val = match.Groups["value"].Value; switch (name) { case "href": _Href = val; break; case "type": _Type = val; break; case "title": _Title = val; break; case "media": _Media = new MediaList(val); break; } match = match.NextMatch(); } ownerNode = pi; }
/// <summary> /// Gets or creates the global lists document. /// </summary> /// <returns></returns> private XmlDocument GetOrCreateGlobalListsXmlDocument(WorkItemStore workItemStore) { if (workItemStore == null) { throw new ArgumentNullException("workItemStore"); } XmlDocument xmlDocument = workItemStore.ExportGlobalLists(); if (xmlDocument != null) { return(xmlDocument); } xmlDocument = new XmlDocument(); //Define encoding for non english languages XmlProcessingInstruction xmlProcessingInstruction = xmlDocument.CreateProcessingInstruction(ProcessingInstructionTarget, ProcessingInstructionData); xmlDocument.AppendChild(xmlProcessingInstruction); var globalListsRoot = xmlDocument.CreateElement(GlobalListsPrefix, GlobalListsIdentifier, GlobalListsNamespace); xmlDocument.AppendChild(globalListsRoot); return(xmlDocument); }
private static void CreateSummaryLog() { Directory.CreateDirectory(resultsDir + "\\Screenshots\\" + testMethodName); summaryLogFileName = "TESTSUMMARY_" + DateTime.Now.ToString("MMddyyyyHHmmss") + ".xml"; summaryLogFullPath = resultsDir + "\\" + summaryLogFileName; XmlDocument doc = new XmlDocument(); FileStream rfile = new FileStream(summaryLogFullPath, FileMode.Create); XmlNode docNode = doc.CreateXmlDeclaration("1.0", "UTF-8", null); doc.AppendChild(docNode); XmlProcessingInstruction xProcess = doc.CreateProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"Template\\Summary.xsl\""); doc.AppendChild(xProcess); XmlNode productsNode = doc.CreateElement("tests"); AddAttributes(productsNode, doc); doc.AppendChild(productsNode); XmlNode testNode = doc.CreateElement("codedui"); XmlAttribute Valueattr = doc.CreateAttribute("name"); Valueattr.Value = testMethodName; testNode.Attributes.Append(Valueattr); productsNode.AppendChild(testNode); XmlNode stestid = doc.CreateElement("testid"); stestid.InnerText = "-"; testNode.AppendChild(stestid); XmlNode sDesc = doc.CreateElement("sDesc"); sDesc.InnerText = "description"; testNode.AppendChild(sDesc); testStartTime = DateTime.Now; XmlNode stTime = doc.CreateElement("starttime"); stTime.InnerText = testStartTime.ToString(); testNode.AppendChild(stTime); XmlNode sStatus = doc.CreateElement("status"); sStatus.InnerText = "InProgress"; testNode.AppendChild(sStatus); XmlNode sFile = doc.CreateElement("file"); sFile.InnerText = debugLogFileName; testNode.AppendChild(sFile); doc.Save(rfile); rfile.Close(); debugLogFullPath = resultsDir + "\\" + debugLogFileName; CreateDebugLog(); }
public void SaveToXml() { XmlDocument doc = new XmlDocument(); XmlProcessingInstruction pi = doc.CreateProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""); doc.AppendChild(pi); XmlElement root = doc.CreateElement("MotionSamples"); doc.AppendChild(root); foreach (KeyValuePair <string, List <SampleData> > pair in datas) { XmlElement motion = doc.CreateElement("Motion"); XmlAttribute name = doc.CreateAttribute("name"); name.Value = pair.Key; motion.Attributes.Append(name); List <SampleData> samples = pair.Value; foreach (SampleData data in samples) { XmlElement sample = doc.CreateElement("Sample"); XmlAttribute time = doc.CreateAttribute("time"); time.Value = data.time.ToString(); sample.Attributes.Append(time); XmlAttribute position = doc.CreateAttribute("position"); position.Value = data.position.ToString(); sample.Attributes.Append(position); XmlAttribute horiAngle = doc.CreateAttribute("hori_angle"); horiAngle.Value = data.horiAngle.ToString(); sample.Attributes.Append(horiAngle); motion.AppendChild(sample); } root.AppendChild(motion); } doc.Save(XML_FILE_NAME); }
public void InitData() { if (Tables == null) { Tables = new List <PdmTable>(); } XmlNode xnTables = xmlDoc.SelectSingleNode("//" + cTables, xmlnsManager); //获取pdm文件指令 XmlProcessingInstruction pi = (XmlProcessingInstruction)xmlDoc.SelectSingleNode("/processing-instruction(\"PowerDesigner\")"); if (pi != null) { var pivalue = pi.Value; //解析指令,获取数据库来源 IList <TagBuilder> tags = TagHelper.ParseSiblingHmlt("<PowerDesigner " + pivalue + " />"); if (tags != null && tags.Count > 0) { DbTypeString = tags[0].GetAttribute("Target"); } } foreach (XmlNode xnTable in xnTables.ChildNodes) { Tables.Add(GetTable(xnTable)); } }
/// <summary>Converts this table back into an excel-readable xml</summary> /// <returns>A long string of all the content, correctly formatted.</returns> public XmlDocument ToExcelXML() { XmlDocument output = new XmlDocument(); XmlNode rootNode = output.CreateElement("Workbook"); // Set general properties for output // Add declaration XmlNode docNode = output.CreateXmlDeclaration("1.0", null, null); output.AppendChild(docNode); XmlProcessingInstruction pi = output.CreateProcessingInstruction("mso-application", "progid=\"Excel.Sheet\""); output.AppendChild(pi); // Add default attributes XmlAttribute attribute = output.CreateAttribute("xmlns"); attribute.Value = "urn:schemas-microsoft-com:office:spreadsheet"; rootNode.Attributes.Append(attribute); attribute = output.CreateAttribute("xmlns:o"); attribute.Value = "urn:schemas-microsoft-com:office:office"; rootNode.Attributes.Append(attribute); attribute = output.CreateAttribute("xmlns:x"); attribute.Value = "urn:schemas-microsoft-com:office:excel"; rootNode.Attributes.Append(attribute); attribute = output.CreateAttribute("xmlns:ss"); attribute.Value = "urn:schemas-microsoft-com:office:spreadsheet"; rootNode.Attributes.Append(attribute); attribute = output.CreateAttribute("xmlns:html"); attribute.Value = "http://www.w3.org/TR/REC-html40"; rootNode.Attributes.Append(attribute); foreach (string key in this.Keys) { // Create node XmlNode worksheet = output.CreateElement("Worksheet"); // Set attributes attribute = output.CreateAttribute("Name", "urn:schemas-microsoft-com:office:spreadsheet"); attribute.Value = key; worksheet.Attributes.Append(attribute); // add content worksheet.AppendChild(this[key].ToExcelXML(output)); // Link to root node rootNode.AppendChild(worksheet); } // Add root to our document output.AppendChild(rootNode); return(output); }
public override void Process(IXmlProcessorNodeList nodeList, IXmlProcessorEngine engine) { XmlProcessingInstruction node = nodeList.Current as XmlProcessingInstruction; engine.AddFlag(node.Data); RemoveItSelf(node); }
private void AppendProcessingInstruction(StringBuilder sb, XmlProcessingInstruction instr) { sb.Append("<?") .Append(instr.Target) .Append(' ').Append(instr.Data) .Append("?>"); }
public static void ReviewProcessingInstruction(XmlDocument _xml, int index) { Console.WriteLine("\nReview:"); XmlProcessingInstruction proc = (XmlProcessingInstruction)_xml.DocumentElement.ChildNodes[index]; Console.WriteLine(" + Name: " + proc.Name); Console.WriteLine(" + Data: " + proc.Data); proc = null; }
static void NodesReview() { if (Document != null) { ConsoleMenu MenuReview = new ConsoleMenu(new List <string>() { "XmlElement", "XmlТext", "XmlComment", "XmlProcessingInstruction", "XmlAttribute", "Back" }); switch (MenuReview.Select()) { case 0: XmlElement element1 = (XmlElement)Document.ChildNodes[4].ChildNodes[2]; Console.WriteLine(element1.ChildNodes[0].LastChild.Value); break; case 1: Console.WriteLine(Document.DocumentElement.ChildNodes[1].OuterXml); break; case 2: Console.WriteLine(Document.DocumentElement.ChildNodes[3].Value); break; case 3: XmlProcessingInstruction myPI = (XmlProcessingInstruction)Document.DocumentElement.ChildNodes[1].ChildNodes[0]; Console.WriteLine("Name: " + myPI.Name); Console.WriteLine("Data: " + myPI.Data); break; case 4: XmlAttributeCollection myAttributes = Document.DocumentElement.ChildNodes[2].Attributes; for (int i = 0; i < myAttributes.Count; i++) { Console.WriteLine("Attribute: " + myAttributes[i].Name + " = " + myAttributes[i].Value); } break; case 5: break; default: Console.WriteLine("Wrong input"); break; } } else { Console.WriteLine("XML document has not been opened"); } }
public static void CreateProcessingInstructionTranslatesNullIntoEmptyString() { var xmlDocument = new XmlDocument(); XmlProcessingInstruction pi = xmlDocument.CreateProcessingInstruction("test", null); Assert.Equal(string.Empty, pi.Data); Assert.Equal(string.Empty, pi.Value); Assert.Equal(string.Empty, pi.InnerText); }
/// <summary> /// Writes RemoteInstall output to an XML file, also generates an XSL file in the same directory to use for XSLT /// </summary> public void Write(Results results, string fileName) { XmlDocument xml = results.GetXml(); string xslFileName = Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName) + ".xsl"); XmlProcessingInstruction pi = xml.CreateProcessingInstruction("xml-stylesheet", string.Format("type=\"text/xsl\" href=\"{0}\"", Path.GetFileName(xslFileName))); xml.InsertAfter(pi, xml.FirstChild); xml.Save(fileName); Xsl.Save(xslFileName); }
/// <summary> /// Creates a new document with a <verticeMetadata> root node and XML preamble /// </summary> public static void EstablishNewDocument() { _xmlDocument = new XmlDocument(); // Add the fundaments of an XML document: the xml processing instruction and a root element XmlProcessingInstruction declareVersionAndEncoding = _xmlDocument.CreateProcessingInstruction("xml", "version='1.0' encoding='UTF-8'"); XmlElement rootElement = _xmlDocument.CreateElement("verticeCollections"); _xmlDocument.AppendChild(declareVersionAndEncoding); _xmlDocument.AppendChild(rootElement); }
public bool SaveShootSolutionSet(string filePath) { XmlDocument doc = new XmlDocument(); XmlProcessingInstruction pPI = doc.CreateProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""); doc.AppendChild(pPI); XmlElement pElementRoot = doc.CreateElement("root"); doc.AppendChild(pElementRoot); XmlElement pNodeDistanceRange = pNodeDistanceRange = doc.CreateElement("distance_range"); pElementRoot.AppendChild(pNodeDistanceRange); foreach (IM.Number distance in m_DistanceList) { XmlElement pNodeDistance = doc.CreateElement("distance"); XmlText pDistanceValue = doc.CreateTextNode(distance.ToString()); pNodeDistanceRange.AppendChild(pNodeDistance); pNodeDistance.AppendChild(pDistanceValue); } XmlElement pNodeAngleRange = doc.CreateElement("angle_range"); pElementRoot.AppendChild(pNodeAngleRange); foreach (IM.Number angle in m_AngleList) { XmlElement pNodeAngle = doc.CreateElement("angle"); XmlText pAngleValue = doc.CreateTextNode(angle.ToString()); pNodeAngleRange.AppendChild(pNodeAngle); pNodeAngle.AppendChild(pAngleValue); } int iSectorCount = m_ShootSolutionSectors.Count; for (int idx = 0; idx < iSectorCount; idx++) { XmlElement pNodeSector = doc.CreateElement("sector"); XmlElement pNodeIndex = doc.CreateElement("index"); XmlElement pNodePath = doc.CreateElement("path"); XmlText pTextIndex = doc.CreateTextNode(idx.ToString()); XmlText pTextPath = doc.CreateTextNode("shoot_" + idx); pElementRoot.AppendChild(pNodeSector); pNodeSector.AppendChild(pNodeIndex); pNodeSector.AppendChild(pNodePath); pNodeIndex.AppendChild(pTextIndex); pNodePath.AppendChild(pTextPath); } doc.Save(filePath + ".xml"); return(true); }
public void SaveIncludes(ArrayList changedIncludeFiles) { foreach (DictionaryEntry entry in fileToNodesMap) { XmlProcessingInstruction include = entry.Key as XmlProcessingInstruction; string file = include.Data.Trim('"', '\r', '\n', ' '); ArrayList nodes = entry.Value as ArrayList; if (changedIncludeFiles.Contains(file) == false) { continue; } XmlDocument includeDoc = new XmlDocument(); XmlElement includeElement = includeDoc.CreateElement("Include", WixFiles.WixNamespaceUri); includeDoc.AppendChild(includeElement); ArrayList obsolete = new ArrayList(); foreach (XmlNode node in nodes) { XmlNode imported = includeDoc.ImportNode(node, true); includeElement.AppendChild(imported); } if (Path.IsPathRooted(file) == false) { file = Path.Combine(wixFiles.WxsDirectory.FullName, file); } FileInfo fileInfo = new FileInfo(file); FileInfo bakFileInfo = new FileInfo(file + ".wixedit.original"); if (fileInfo.Exists) { if (WixEditSettings.Instance.BackupChangedIncludes && bakFileInfo.Exists == false) { fileInfo.CopyTo(bakFileInfo.FullName); } UnauthorizedAccessException theEx = null; do { try { includeDoc.Save(fileInfo.FullName); break; } catch (UnauthorizedAccessException ex) { theEx = ex; } } while (DialogResult.Retry == MessageBox.Show("Failed to save include file. " + theEx.Message, "Failed to save include file", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning)); } } }
/// <summary> /// Write to a file as XML Dcoument. /// </summary> public void Write(FileStream fileStream) { XmlProcessingInstruction xDeclaration = _xDocument.CreateProcessingInstruction("xml", @"version=""1.0"""); //宣言の追加 _xDocument.AppendChild(xDeclaration); //ServerSettingsの追加 _xDocument.AppendChild(_xRoot); _xDocument.Save(fileStream); }
public String getProcessingInstr() { XmlProcessingInstruction instruction = doc.SelectSingleNode("processing-instruction('xml-stylesheet')") as XmlProcessingInstruction; if (instruction == null) { throw new Exception("Can't find processing instructions\n"); } return(instruction.Data); }