本文整理匯總了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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}