本文整理汇总了C#中System.Xml.XmlDocument.CreateXmlDeclaration方法的典型用法代码示例。如果您正苦于以下问题:C# System.Xml.XmlDocument.CreateXmlDeclaration方法的具体用法?C# System.Xml.XmlDocument.CreateXmlDeclaration怎么用?C# System.Xml.XmlDocument.CreateXmlDeclaration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlDocument
的用法示例。
在下文中一共展示了System.Xml.XmlDocument.CreateXmlDeclaration方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Xml
public Xml(string rootName)
{
_xml = new System.Xml.XmlDocument();
System.Xml.XmlDeclaration dec = _xml.CreateXmlDeclaration("1.0", null, null);
_xml.AppendChild(dec);
_root = _xml.CreateElement(rootName);
_xml.AppendChild(_root);
}
示例2: GetXml
/// <summary>
/// Get the xml for this list of datasets
/// </summary>\
/// <param name="oDapCommand"></param>
/// <param name="oDatasets"></param>
/// <param name="oSelectedDatasets"></param>
/// <returns></returns>
public static System.Xml.XmlDocument GetXml(Command oDapCommand, System.Collections.SortedList oDatasets, System.Collections.ArrayList oSelectedDatasets)
{
System.Xml.XmlDocument oOutputXml = new System.Xml.XmlDocument();
oOutputXml.AppendChild(oOutputXml.CreateXmlDeclaration("1.0", "UTF-8", string.Empty));
System.Xml.XmlElement oGeosoftXml = oOutputXml.CreateElement("geosoft_xml");
oOutputXml.AppendChild(oGeosoftXml);
foreach (string strKey in oSelectedDatasets)
{
Dap.Common.DataSet oDataset = (Dap.Common.DataSet)oDatasets[strKey];
if (oDataset != null)
OutputDataset(oDapCommand, oGeosoftXml, oDataset);
}
return oOutputXml;
}
示例3: Serialize
/// <include file='doc\IFormatter.uex' path='docs/doc[@for="IFormatter.Serialize"]/*' />
public void Serialize(Stream serializationStream, Object graph)
{
AccuDataObjectFormatter = new System.Xml.XmlDocument();
System.Xml.XmlDeclaration Declaration = AccuDataObjectFormatter.CreateXmlDeclaration("1.0", "", "");
System.Xml.XmlElement Element = AccuDataObjectFormatter.CreateElement("NewDataSet");
if (graph != null)
{
if (graph.GetType().Equals(typeof(System.String)))
{
Element.InnerText = graph.ToString();
}
else if (graph.GetType().GetInterface("IEnumerable") != null)
{
Serialize(Element, graph);
}
else if (graph.GetType().IsArray)
{
Serialize(Element, graph);
}
else if (graph.GetType().IsClass)
{
Serialize(Element, graph);
}
else if (graph.GetType().IsPrimitive)
{
Element.InnerText = graph.ToString();
}
else if (graph.GetType().IsValueType)
{
System.Xml.XmlElement ValueType = AccuDataObjectFormatter.CreateElement(graph.GetType().Name);
Element.AppendChild(ValueType);
}
}
AccuDataObjectFormatter.AppendChild(Declaration);
AccuDataObjectFormatter.AppendChild(Element);
System.IO.StreamWriter writer = new StreamWriter(serializationStream);
writer.Write(AccuDataObjectFormatter.OuterXml);
writer.Flush();
writer.BaseStream.Seek(0, System.IO.SeekOrigin.Begin);
}
示例4: GetKML
/// <summary>
/// Get the kml for this list of datasets
/// </summary>
/// <param name="strWmsUrl"></param>
/// <param name="oDatasets"></param>
/// <param name="oSelectedDatasets"></param>
/// <returns></returns>
public static System.Xml.XmlDocument GetKML(string strWmsUrl, System.Collections.SortedList oDatasets, System.Collections.ArrayList oSelectedDatasets)
{
System.Xml.XmlDocument oOutputXml = new System.Xml.XmlDocument();
oOutputXml.AppendChild(oOutputXml.CreateXmlDeclaration("1.0", "UTF-8", string.Empty));
System.Xml.XmlElement oKml = oOutputXml.CreateElement("kml", "http://earth.google.com/kml/2.1");
oOutputXml.AppendChild(oKml);
System.Xml.XmlElement oDocument = oOutputXml.CreateElement("Document", "http://earth.google.com/kml/2.1");
System.Xml.XmlAttribute oAttr = oOutputXml.CreateAttribute("id");
oAttr.Value = "Geosoft";
oDocument.Attributes.Append(oAttr);
oKml.AppendChild(oDocument);
System.Xml.XmlElement oName = oOutputXml.CreateElement("name", "http://earth.google.com/kml/2.1");
oName.InnerText = "Geosoft Catalog";
oDocument.AppendChild(oName);
System.Xml.XmlElement oVisibility = oOutputXml.CreateElement("visibility", "http://earth.google.com/kml/2.1");
oVisibility.InnerText = "1";
oDocument.AppendChild(oVisibility);
System.Xml.XmlElement oOpen = oOutputXml.CreateElement("open", "http://earth.google.com/kml/2.1");
oOpen.InnerText = "1";
oDocument.AppendChild(oOpen);
foreach (string strKey in oSelectedDatasets)
{
Dap.Common.DataSet oDataset = (Dap.Common.DataSet)oDatasets[strKey];
if (oDataset != null)
OutputDataset(strWmsUrl, oDocument, oDataset);
}
return oOutputXml;
}
示例5: SaveConfig
internal static void SaveConfig()
{
{
var rf = GetRecentFiles();
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
System.Xml.XmlElement project_root = doc.CreateElement("Recent");
foreach (var f in rf.Reverse())
{
project_root.AppendChild(doc.CreateTextElement("File", f));
}
doc.AppendChild(project_root);
var dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);
doc.InsertBefore(dec, project_root);
doc.Save(configRecentPath);
}
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
System.Xml.XmlElement project_root = doc.CreateElement("GUI");
if (MainForm.WindowState == FormWindowState.Normal)
{
project_root.AppendChild(doc.CreateTextElement("X", MainForm.Location.X.ToString()));
project_root.AppendChild(doc.CreateTextElement("Y", MainForm.Location.Y.ToString()));
project_root.AppendChild(doc.CreateTextElement("Width", MainForm.Width.ToString()));
project_root.AppendChild(doc.CreateTextElement("Height", MainForm.Height.ToString()));
}
else // 最小化、最大化中はその前の位置とサイズを保存
{
project_root.AppendChild(doc.CreateTextElement("X", MainForm.BeforeResizeLocation.X.ToString()));
project_root.AppendChild(doc.CreateTextElement("Y", MainForm.BeforeResizeLocation.Y.ToString()));
project_root.AppendChild(doc.CreateTextElement("Width", MainForm.BeforeResizeWidth.ToString()));
project_root.AppendChild(doc.CreateTextElement("Height", MainForm.BeforeResizeHeight.ToString()));
}
doc.AppendChild(project_root);
var dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);
doc.InsertBefore(dec, project_root);
doc.Save(configGuiPath);
}
MainForm.Panel.SaveAsXml(configGuiPanelPath, Encoding.UTF8);
Network.Save(configNetworkPath);
}
示例6: CreateDocument
public static multiTable2oneXML_spy2 CreateDocument(string encoding)
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.AppendChild(doc.CreateXmlDeclaration("1.0", encoding, null));
return new multiTable2oneXML_spy2(doc);
}
示例7: Read
public void Read(string Filename)
{
// now load this bugger up and get rid or all the junk that WMP can't parse
System.Xml.XmlDocument xmld = new System.Xml.XmlDocument();
xmld.Load(Filename);
System.Xml.XmlDeclaration xmldecl = xmld.CreateXmlDeclaration("1.0",null,null);
xmld.InsertBefore(xmldecl,xmld.DocumentElement);
string TempFile = System.IO.Path.GetTempFileName();
xmld.Save(TempFile);
System.IO.TextReader tw = System.IO.File.OpenText(TempFile);
m_asx = (CarverLab.Utility.ASX)base.Deserialize(tw);
tw.Close();
System.IO.File.Delete(TempFile);
}
示例8: CreateDocument
public static Asn1OutXml2 CreateDocument(string encoding)
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.AppendChild(doc.CreateXmlDeclaration("1.0", encoding, null));
return new Asn1OutXml2(doc);
}
示例9: SaveDruzina
public void SaveDruzina(TreeNode tnode)
{
String file = tnode.Tag.ToString();
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.AppendChild(doc.CreateXmlDeclaration("1.0", "UTF-8", ""));
System.Xml.XmlElement root = doc.CreateElement("druzina");
System.Xml.XmlAttribute att = doc.CreateAttribute("nazev");
att.Value = tnode.Text;
root.Attributes.Append(att);
foreach (TreeNode n in tnode.Nodes)
{
((Postava)n.Tag).Save();
System.Xml.XmlNode node = doc.CreateElement("postava");
node.AppendChild(doc.CreateTextNode(((Postava)n.Tag).xmlFileName));
root.AppendChild(node);
}
doc.AppendChild(root);
doc.Save(file);
}
示例10: CheckAndFixXMLInput
void CheckAndFixXMLInput(string Filename)
{
System.Xml.XmlDocument xmld = new System.Xml.XmlDocument();
xmld.Load(Filename);
if (xmld.FirstChild.NodeType != System.Xml.XmlNodeType.XmlDeclaration)
{
System.Xml.XmlAttribute atr;
System.Xml.XmlNode node;
DateTime dt;
atr = xmld.CreateAttribute("xmlns:xsd");
atr.Value = "http://www.w3.org/2001/XMLSchema";
xmld.FirstChild.Attributes.Append(atr);
atr = xmld.CreateAttribute("xmlns:xsi");
atr.Value = "http://www.w3.org/2001/XMLSchema-instance" ;
xmld.FirstChild.Attributes.Append(atr);
atr = xmld.CreateAttribute("xmlns");
atr.Value = "http://carverlab.com/xsd/VideoExchange.xsd";
xmld.FirstChild.Attributes.Append(atr);
xmld.InsertBefore(xmld.CreateXmlDeclaration("1.0","utf-8",""),xmld.FirstChild);
node = xmld.SelectSingleNode("CARDVIDEO/TIMESTART");
dt = DateTime.Parse(node.InnerText);
node.InnerText = dt.ToString("s",System.Globalization.DateTimeFormatInfo.InvariantInfo);
node = xmld.SelectSingleNode("CARDVIDEO/TIMESTOP");
dt = DateTime.Parse(node.InnerText);
node.InnerText = dt.ToString("s",System.Globalization.DateTimeFormatInfo.InvariantInfo);
xmld.Save(Filename);
}
}
示例11: CreateDocument
public static connStringConfig2 CreateDocument(string encoding)
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.AppendChild(doc.CreateXmlDeclaration("1.0", encoding, null));
return new connStringConfig2(doc);
}
示例12: GetSkin
public Skin GetSkin()
{
var resources = new Dictionary<string, System.IO.MemoryStream>();
var doc = new System.Xml.XmlDocument();
var declar = doc.CreateXmlDeclaration("1.0", System.Text.Encoding.UTF8.WebName, null);
doc.AppendChild(declar);
var root = doc.CreateElement("Theme");
root.SetAttribute("version", "1.0");
root.AppendChild(this.ContainerControl.GetXmlElement(doc, resources));
doc.AppendChild(root);
return new Skin(doc, resources);
}
示例13: guardarXML
private void guardarXML(Stream myStream)
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
//System.Xml.XmlAttribute atributo;
System.Xml.XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", "UTF-8", "");
doc.AppendChild(declaration);
System.Xml.XmlNode pmml = doc.CreateElement("PMML");
/*
atributo = doc.CreateAttribute("version");
atributo.InnerText = "3.0";
pmml.Attributes.Append(atributo);
atributo = doc.CreateAttribute("xmlns");
atributo.InnerText = "http://www.dmg.org/PMML-3-0";
pmml.Attributes.Append(atributo);
atributo = doc.CreateAttribute("xmlns:xsi");
atributo.InnerText = "http://www.w3.org/2001/XMLSchema_instance";
pmml.Attributes.Append(atributo);
*/
pmml.Attributes.Append(setAtributo(doc, "version", "3.0"));
pmml.Attributes.Append(setAtributo(doc, "xmlns", "http://www.dmg.org/PMML-3-0"));
pmml.Attributes.Append(setAtributo(doc, "xmlns:xsi", "http://www.w3.org/2001/XMLSchema_instance"));
doc.AppendChild(pmml);
System.Xml.XmlNode sprite = doc.CreateElement("TEXTURA");
if (textureName.Text.Equals(""))
sprite.Attributes.Append(setAtributo(doc,"Name","none"));
else
sprite.Attributes.Append(setAtributo(doc, "Name", textureName.Text));
if (useRelativePath.Checked && !relativeFileLoc.Equals(""))
sprite.Attributes.Append(setAtributo(doc, "TextureFile", relativeFileLoc.Insert(0,"..\\").Replace('\\','/')));
else
sprite.Attributes.Append(setAtributo(doc, "TextureFile", fileLoc));
int colorR = color_click.BackColor.R;
int colorG = color_click.BackColor.G;
int colorB = color_click.BackColor.B;
//sprite.Attributes.Append(setAtributo(doc, "ColorKey", "FF"+R+G+B));
System.Xml.XmlNode colorKey = doc.CreateElement("ColorKey");
colorKey.Attributes.Append(setAtributo(doc, "R", colorR.ToString()));
colorKey.Attributes.Append(setAtributo(doc, "G", colorG.ToString()));
colorKey.Attributes.Append(setAtributo(doc, "B", colorB.ToString()));
sprite.AppendChild(colorKey);
pmml.AppendChild(sprite);
/*
doc.AppendChild(XClub);
System.Xml.XmlNode Pelicula = doc.CreateElement("Pelicula");
XClub.AppendChild(Pelicula);
System.Xml.XmlNode Data = doc.CreateElement("Data");
System.Xml.XmlAttribute atributo = doc.CreateAttribute("Titulo");
atributo.InnerText = "Garganta Profunda(Deep Throat)";
Data.Attributes.Append(atributo);
System.Xml.XmlAttribute atributo2 = doc.CreateAttribute("Director");
atributo2.InnerText = "";
Data.Attributes.Append(atributo2);
Pelicula.AppendChild(Data);*/
doc.Save(myStream);
}
示例14: CreateDocument
public static streamTypeDefine2 CreateDocument(string encoding)
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.AppendChild(doc.CreateXmlDeclaration("1.0", encoding, null));
return new streamTypeDefine2(doc);
}
示例15: SaveState
private void SaveState()
{
//file queue
System.Xml.XmlDocument XmlDoc = new System.Xml.XmlDocument();
XmlDoc.AppendChild(XmlDoc.CreateElement("nzb"));
foreach( Article article in m_ServerManager.m_Articles)
{
if( article.Status == ArticleStatus.Decoded || article.Status == ArticleStatus.Deleted || article.Status == ArticleStatus.Error)
continue;
System.Xml.XmlNode XmlArticle = XmlDoc.CreateElement( "file");
DateTime Date = new DateTime(1970, 1, 1, 0, 0, 0, 0);
XmlAddAttr( XmlArticle, "subject", article.Subject);
XmlAddAttr( XmlArticle, "date", ((long)article.Date.Subtract(Date).TotalSeconds).ToString());
XmlAddAttr( XmlArticle, "poster", article.Poster);
XmlAddAttr( XmlArticle, "importfile", article.ImportFile);
System.Xml.XmlNode XmlGroups = XmlDoc.CreateElement( "groups");
foreach( string group in article.Groups)
{
System.Xml.XmlNode XmlGroup = XmlDoc.CreateElement( "group");
XmlGroup.InnerText = group;
XmlGroups.AppendChild( XmlGroup);
}
XmlArticle.AppendChild( XmlGroups);
System.Xml.XmlNode XmlSegments = XmlDoc.CreateElement( "segments");
foreach( Segment segment in article.Segments)
{
System.Xml.XmlNode XmlSegment = XmlDoc.CreateElement( "segment");
XmlAddAttr( XmlSegment, "bytes", segment.Bytes.ToString());
XmlAddAttr( XmlSegment, "number", segment.Number.ToString());
XmlSegment.InnerText = segment.ArticleID;
XmlSegments.AppendChild( XmlSegment);
}
XmlArticle.AppendChild( XmlSegments);
XmlDoc.DocumentElement.AppendChild(XmlArticle);
}
XmlDoc.Save(Global.m_DataDirectory + "nzb-o-matic.xml");
//servers
System.Xml.XmlDocument ServerDoc = new System.Xml.XmlDocument();
System.Xml.XmlDeclaration decleration = ServerDoc.CreateXmlDeclaration("1.0", "utf-8", "");
ServerDoc.AppendChild(decleration);
//create server groups element
System.Xml.XmlNode servergroups = ServerDoc.CreateElement("servergroups");
//loop through each servergroup
foreach(ServerGroup sgs in m_ServerManager.m_ServerGroups)
{
//create servergroup tag
System.Xml.XmlNode servergroup = ServerDoc.CreateElement("servergroup");
//create servers tag
System.Xml.XmlNode servers = ServerDoc.CreateElement("servers");
//loop through each server
foreach(Server serv in sgs.Servers)
{
//add server tag
System.Xml.XmlNode snode = ServerDoc.CreateElement("server");
XmlAddAttr(snode, "enabled", serv.Enabled.ToString());
XmlAddElement(snode, "address", serv.Hostname);
XmlAddElement(snode, "port", serv.Port.ToString());
//add login
System.Xml.XmlNode login = ServerDoc.CreateElement("login");
if(serv.RequiresLogin)
{
XmlAddElement(login, "username", serv.Username);
XmlAddElement(login, "password", serv.Password);
}
snode.AppendChild(login);
XmlAddElement(snode, "connections", serv.NoConnections.ToString());
XmlAddElement(snode, "needsgroup", serv.NeedsGroup.ToString());
XmlAddElement(snode, "ssl", serv.UseSSL.ToString());
//add server to servers
servers.AppendChild(snode);
}
//add servers to servergroup
servergroup.AppendChild(servers);
//add servergroup to servergroups
servergroups.AppendChild(servergroup);
}
ServerDoc.AppendChild(servergroups);
ServerDoc.Save(Global.m_DataDirectory + "servers.xml");
//options
System.Xml.XmlDocument OptionsDoc = new System.Xml.XmlDocument();
//.........这里部分代码省略.........