當前位置: 首頁>>代碼示例>>C#>>正文


C# XmlDocument.CreateProcessingInstruction方法代碼示例

本文整理匯總了C#中System.Xml.XmlDocument.CreateProcessingInstruction方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlDocument.CreateProcessingInstruction方法的具體用法?C# XmlDocument.CreateProcessingInstruction怎麽用?C# XmlDocument.CreateProcessingInstruction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Xml.XmlDocument的用法示例。


在下文中一共展示了XmlDocument.CreateProcessingInstruction方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SerializeXml

        //ArrayList openElements = new ArrayList();
        public void SerializeXml(IList<StarSystem> starSystems)
        {
            MemoryStream memXmlStream = new MemoryStream();
            XmlSerializer serializer = new XmlSerializer(starSystems.GetType(), null, new Type[] { typeof(Planet), typeof(StarSystem) }, new XmlRootAttribute("Stars"), null, null);

            serializer.Serialize(memXmlStream, starSystems);

            XmlDocument xmlDoc = new XmlDocument();

            memXmlStream.Seek(0, SeekOrigin.Begin);
            xmlDoc.Load(memXmlStream);

            XmlProcessingInstruction newPI;
            String PItext = string.Format("type='text/xsl' href='{0}'", "system.xslt");
            newPI = xmlDoc.CreateProcessingInstruction("xml-stylesheet", PItext);

            xmlDoc.InsertAfter(newPI, xmlDoc.FirstChild);

            // Now write the document

            // out to the final output stream

            XmlTextWriter wr = new XmlTextWriter("system.xml", System.Text.Encoding.ASCII);
            wr.Formatting = Formatting.Indented;
            wr.IndentChar = '\t';
            wr.Indentation = 1;

            XmlWriterSettings settings = new XmlWriterSettings();
            XmlWriter writer = XmlWriter.Create(wr, settings);

            xmlDoc.WriteTo(writer);
            writer.Flush();
            //Console.Write(xmlDoc.InnerXml);
        }
開發者ID:sveco,項目名稱:AccreteSharp,代碼行數:35,代碼來源:SystemDisplayXml.cs

示例2: ConvertActToXml

		// 02/02/2010   ACT Database Import is a Professional/Enterprise feature. 
		public static XmlDocument ConvertActToXml(string sImportModule, Stream stm)
		{
			XmlDocument xml = new XmlDocument();
			xml.AppendChild(xml.CreateProcessingInstruction("xml" , "version=\"1.0\" encoding=\"UTF-8\""));
			xml.AppendChild(xml.CreateElement("xml"));
			return xml;
		}
開發者ID:huamouse,項目名稱:Taoqi,代碼行數:8,代碼來源:ACTImport.cs

示例3: MakeRoot

        protected internal void MakeRoot(string namespaceURI, string rootElementName, string schemaLocation)
        {
            XmlDocument doc = new XmlDocument();
            XmlElement root = doc.CreateElement(rootElementName, namespaceURI);

            doc.AppendChild(doc.CreateProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""));
            doc.AppendChild(root);

            root.SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
            if (namespaceURI == null || namespaceURI == "")
            {
                if (schemaLocation != null && schemaLocation != "")
                {
                    XmlAttribute a = doc.CreateAttribute("xsi:noNamespaceSchemaLocation", "http://www.w3.org/2001/XMLSchema-instance");
                    a.Value = schemaLocation;
                    root.SetAttributeNode(a);
                }
            }
            else
            {
                if (schemaLocation != null && schemaLocation != "")
                {
                    XmlAttribute a = doc.CreateAttribute("xsi:schemaLocation", "http://www.w3.org/2001/XMLSchema-instance");
                    a.Value = namespaceURI + " " + schemaLocation;
                    root.SetAttributeNode(a);
                }
            }

            foreach (XmlAttribute attribute in domNode.Attributes)
                root.Attributes.Append((XmlAttribute)doc.ImportNode(attribute, true));
            foreach (XmlNode childNode in domNode.ChildNodes)
                root.AppendChild(doc.ImportNode(childNode, true));

            domNode = root;
        }
開發者ID:BackupTheBerlios,項目名稱:ntssapi-svn,代碼行數:35,代碼來源:Node.cs

示例4: ConvertFromPHP

        public static string ConvertFromPHP(string sPHP)
        {
            XmlDocument xml = new XmlDocument();
            xml.AppendChild(xml.CreateProcessingInstruction("xml" , "version=\"1.0\" encoding=\"UTF-8\""));
            xml.AppendChild(xml.CreateElement("USER_PREFERENCE"));
            try
            {
                byte[] abyPHP = Convert.FromBase64String(sPHP);
                StringBuilder sb = new StringBuilder();
                foreach(char by in abyPHP)
                    sb.Append(by);
                MemoryStream mem = new MemoryStream(abyPHP);

                string sSize = String.Empty;
                int nChar = mem.ReadByte();
                while ( nChar != -1 )
                {
                    char ch = Convert.ToChar(nChar);
                    if ( ch == 'a' )
                        PHPArray(xml, xml.DocumentElement, mem);
                    else if ( ch == 's' )
                        PHPString(mem);
                    else if ( ch == 'i' )
                        PHPInteger(mem);
                    nChar = mem.ReadByte();
                }
            }
            catch(Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
            }
            return xml.OuterXml;
        }
開發者ID:NALSS,項目名稱:splendidcrm-99885,代碼行數:33,代碼來源:XmlUtil.cs

示例5: GetXml

 public XmlDocument GetXml(String xslFile)
 {
     XmlDocument doc = new XmlDocument();
       XmlElement root = doc.CreateElement("licenses");
       doc.AppendChild(root);
       if (!String.IsNullOrEmpty(xslFile))
       {
     XmlNode pi = doc.CreateProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"" + xslFile + "\"");
     doc.InsertBefore(pi, root);
       }
       foreach (LicenseInfo license in _licenses.Values)
       {
     XmlElement licenseElement = doc.CreateElement("license");
     licenseElement.SetAttribute("productName", license.Product);
     licenseElement.SetAttribute("productVersion", license.Version);
     if (!String.IsNullOrEmpty(license.ParentProduct))
     {
       licenseElement.SetAttribute("parentProduct", license.ParentProduct);
     }
     if (!String.IsNullOrEmpty(license.LicenseFilename))
     {
       licenseElement.SetAttribute("filename", license.LicenseFilename);
     }
     if (!String.IsNullOrEmpty(license.LicenseType))
     {
       licenseElement.SetAttribute("licenseType", license.LicenseType);
     }
     if (!String.IsNullOrEmpty(license.Url))
     {
       licenseElement.SetAttribute("url", license.Url);
     }
     root.AppendChild(licenseElement);
       }
       return doc;
 }
開發者ID:pombredanne,項目名稱:3licenses,代碼行數:35,代碼來源:LicenseFilesManifest.cs

示例6: Save

        public void Save(string fileName)
        {
            if (this.Messages.Count == 0 || string.IsNullOrEmpty(fileName)) return;
            if (File.Exists(fileName)) File.Delete(fileName);

            var xml = new XmlDocument();
            xml.AppendChild(xml.CreateXmlDeclaration(this.Declaration.Version, this.Declaration.Encoding, this.Declaration.Standalone));
            xml.AppendChild(xml.CreateProcessingInstruction(this.Xsl.Target, this.Xsl.Data));

            var root = xml.CreateElement("Log");
            root.SetAttribute("FirstSessionID", this.Messages[0].SessionID.ToString());
            root.SetAttribute("LastSessionID", this.Messages[this.Messages.Count - 1].SessionID.ToString());

            xml.AppendChild(root);
            this.Messages.ForEach(messageNode =>
                {
                    var nodeName = messageNode.GetType().Name.Replace("Msn", string.Empty);
                    var newNode = xml.CreateElement(nodeName);
                    root.AppendChild(messageNode.GenerateXmlNode(newNode));
                });

            var writer = new XmlTextWriter(fileName, Encoding.UTF8);
            writer.WriteRaw(xml.OuterXml);
            writer.Flush();
            writer.Close();
        }
開發者ID:jerecui,項目名稱:MSNChatHistoryCombiner,代碼行數:26,代碼來源:MsnLog.cs

示例7: SaveToFile

	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;
	}
開發者ID:emtees,項目名稱:old-code,代碼行數:30,代碼來源:mwncontributor.cs

示例8: BasicCreate

        public static void BasicCreate()
        {
            var xmlDocument = new XmlDocument();
            var newNode = xmlDocument.CreateProcessingInstruction("bar", "foo");

            Assert.Equal("<?bar foo?>", newNode.OuterXml);
            Assert.Equal(XmlNodeType.ProcessingInstruction, newNode.NodeType);
        }
開發者ID:johnhhm,項目名稱:corefx,代碼行數:8,代碼來源:CreateProcessingInstruction.cs

示例9: MakeRequestDocument

 public static XmlDocument MakeRequestDocument()
 {
     XmlDocument inputXMLDoc = null;
     inputXMLDoc = new XmlDocument();
     inputXMLDoc.AppendChild(inputXMLDoc.CreateXmlDeclaration("1.0", null, null));
     inputXMLDoc.AppendChild(inputXMLDoc.CreateProcessingInstruction("qbxml", "version=\"12.0\""));
     return inputXMLDoc;
 }
開發者ID:ZochNet,項目名稱:QBMigrationTool,代碼行數:8,代碼來源:XmlUtils.cs

示例10: XmlPolicyLanguageWriter

        public XmlPolicyLanguageWriter(XmlPolicyLanguageStore store)
        {
            m_languageStore = store;

            m_xmlDocument = new XmlDocument();
            XmlProcessingInstruction processingInstruction = m_xmlDocument.CreateProcessingInstruction("xml", "version=\"1.0\" encoding=\"utf-8\"");
            m_xmlDocument.AppendChild(processingInstruction);
            m_xmlLanguageNode = m_xmlDocument.CreateElement("PolicySetLanguage");
            m_xmlDocument.AppendChild(m_xmlLanguageNode);
        }
開發者ID:killbug2004,項目名稱:WSProf,代碼行數:10,代碼來源:XmlPolicyLanguageWriter.cs

示例11: InsertNewNodeToElement

        public static void InsertNewNodeToElement()
        {
            var xmlDocument = new XmlDocument();
            xmlDocument.LoadXml("<a><b/></a>");
            var root = xmlDocument.DocumentElement;
            var newNode = xmlDocument.CreateProcessingInstruction("PI", "pi data");

            root.InsertBefore(newNode, root.FirstChild);

            Assert.Equal(2, root.ChildNodes.Count);
        }
開發者ID:johnhhm,項目名稱:corefx,代碼行數:11,代碼來源:InsertBeforeTests.cs

示例12: CreateDocument

 private void CreateDocument()
 {
     m_xmlDocument = new XmlDocument();
     XmlProcessingInstruction processingInstruction = m_xmlDocument.CreateProcessingInstruction("xml", "version=\"1.0\" encoding=\"utf-8\"");
     m_xmlDocument.AppendChild(processingInstruction);
     m_catalogue = m_xmlDocument.CreateElement("PolicySetCatalogue");
     XmlHelpers.AddAttribute(m_catalogue, "id", m_catalogueGuid.ToString("B", CultureInfo.InvariantCulture).ToUpper(CultureInfo.InvariantCulture));
     XmlHelpers.AddAttribute(m_catalogue, "languageId", m_languageGuid.ToString("B", CultureInfo.InvariantCulture).ToUpper(CultureInfo.InvariantCulture));
     XmlHelpers.AddAttribute(m_catalogue, "name", "");
     m_xmlDocument.AppendChild(m_catalogue);
 }
開發者ID:killbug2004,項目名稱:WSProf,代碼行數:11,代碼來源:XmlPolicyCatalogueWriter.cs

示例13: createDocument

 protected XmlNode createDocument(string rootName, string schemaLocation)
 {
     dom = new XmlDocument();
     XmlNode xmlNode = dom.CreateProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
     dom.AppendChild(xmlNode);
     XmlNode root = dom.CreateNode(XmlNodeType.Element, prefix, rootName, nameSpace);
     addStringAttribute(root, "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
     XmlAttribute schema = dom.CreateAttribute("xsi", "schemaLocation", "http://www.w3.org/2001/XMLSchema-instance");
     schema.Value = schemaLocation;
     root.Attributes.Append(schema);
     return root;
 }
開發者ID:njmube,項目名稱:CFDI-3,代碼行數:12,代碼來源:CFDBase.cs

示例14: GetAsXml

 public XmlDocument GetAsXml()
 {
     var doc = new XmlDocument();
     var dec = doc.CreateXmlDeclaration("1.0", null, null);
     doc.AppendChild(dec);
     var pi = doc.CreateProcessingInstruction("xml-stylesheet", @"type='text/xsl' href='FactorStatistics.xslt'");
     doc.AppendChild(pi);
     XmlElement root = doc.CreateElement("RaceAnalysis");
     doc.AppendChild(root);
     _analyzers.ForEach(analyzer => analyzer.AddToXmlDocument(doc,root));
     return doc;
 }
開發者ID:jpazarzis,項目名稱:hogar,代碼行數:12,代碼來源:RaceAnalyzer.cs

示例15: GetErrorDocument

        public static XmlDocument GetErrorDocument(string errormessage)
        {
            XmlDocument errorDoc = new XmlDocument();

            errorDoc.AppendChild(errorDoc.CreateProcessingInstruction("xml-stylesheet", "type='text/xsl' href='xsl/errorPage.xsl'"));
            XmlNode root = errorDoc.AppendChild(errorDoc.CreateNode(XmlNodeType.Element, "root", null));
            XmlNode node = root.AppendChild(errorDoc.CreateNode(XmlNodeType.Element, "message", null));

            node.InnerText = errormessage;

            Timingutil.info("Compile Error ! , generate ErrorDom");
            return errorDoc;
        }
開發者ID:sebseb7,項目名稱:xsphandler_sharp,代碼行數:13,代碼來源:commonutil.cs


注:本文中的System.Xml.XmlDocument.CreateProcessingInstruction方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。