本文整理汇总了C#中System.Xml.XmlDocument.Save方法的典型用法代码示例。如果您正苦于以下问题:C# System.Xml.XmlDocument.Save方法的具体用法?C# System.Xml.XmlDocument.Save怎么用?C# System.Xml.XmlDocument.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlDocument
的用法示例。
在下文中一共展示了System.Xml.XmlDocument.Save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadData
public void LoadData(bool show_error)
{
buttonAggiorna.Enabled = numStagione.Enabled = false;
try
{
Internal.Main.StatusString = "Download dell'elenco delle partite in corso...";
string stagione = numStagione.Value.ToString();
string url = string.Format(@"http://www.rugbymania.net/export_xml_part.php?lang=italiano&season={2}&id={0}&access_key={1}&object=calendar",
Properties.Settings.Default.RM_Id, Properties.Settings.Default.RM_Codice, stagione);
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
try
{
doc.Load(url);
}
catch (Exception ex)
{
if (show_error) My.Box.Errore("Impossibile scaricare i dati delle partite\r\n"+ex.Message);
if (System.IO.File.Exists(DEFAULT_DATA)) doc.Load(DEFAULT_DATA);
}
Internal.Main.StatusString = "Download dell'elenco delle partite terminato!";
ShowPartite(doc);
if (doc.HasChildNodes) doc.Save(DEFAULT_DATA);
}
catch (Exception ex)
{
#if(DEBUG)
My.Box.Info("TabClassifica::LoadData\r\n" + ex.Message);
#endif
Internal.Main.Error_on_xml();
}
buttonAggiorna.Enabled = numStagione.Enabled = true;
}
示例2: Main
static void Main(string[] args)
{
string applicationDirectory = System.Reflection.Assembly.GetExecutingAssembly().Location;
applicationDirectory = applicationDirectory.Substring(0, applicationDirectory.LastIndexOf(@"\")+1);
using (StreamReader reader = File.OpenText( FilePath ) )
{
string line = null;
do
{
line = reader.ReadLine();
if (line != null)
{
string[] items = line.Split(',');
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
string url = items[XmlColumn];
try
{
doc.Load(url);
string filename = items[XmlColumn].Substring(items[XmlColumn].LastIndexOf("/") + 1);
string filepath = Path.Combine(applicationDirectory, SaveFolder, filename);
doc.Save(filepath);
}
catch (Exception e)
{
Console.WriteLine("Exception: " + url + "\r\n" + e.Message);
}
}
}
while( line != null );
}
Console.Write("Press Enter key to close. ");
while( Console.ReadKey().Key != ConsoleKey.Enter );
}
示例3: btnPublishFolder_Click
private void btnPublishFolder_Click(object sender, EventArgs e)
{
if (!String.IsNullOrEmpty(txtFolderPath.Text))
{
//To Publish Folder, add Data to XML
System.Xml.XmlDocument objXmlDocument = new System.Xml.XmlDocument();
// Load XML
objXmlDocument.Load(@".\Data\PublishedFolders.xml");
System.Xml.XmlNode objXmlNode = objXmlDocument.CreateNode(System.Xml.XmlNodeType.Element,"Folder", "Folder");
// Attribute Name
System.Xml.XmlAttribute objXmlAttribute = objXmlDocument.CreateAttribute("Name");
objXmlAttribute.Value = "Carpeta";
objXmlNode.Attributes.Append(objXmlAttribute);
// Attribute Status
objXmlAttribute = objXmlDocument.CreateAttribute("Status");
objXmlAttribute.Value = "Enabled";
objXmlNode.Attributes.Append(objXmlAttribute);
// Attribute Path
objXmlAttribute = objXmlDocument.CreateAttribute("Path");
objXmlAttribute.Value = txtFolderPath.Text;
objXmlNode.Attributes.Append(objXmlAttribute);
// Add Node
objXmlDocument.SelectSingleNode("/PublishedFolders").AppendChild(objXmlNode);
// Update File
objXmlDocument.Save(@".\Data\PublishedFolders.xml");
// Refresh List
LoadFolders();
}
}
示例4: reload_Click
private void reload_Click(object sender, EventArgs e)
{
String firstNum, lastNum;
// Gets the first 4 and last 4 numbers from the Selectionbox, and saves them to a variable
firstNum = resolutionSelect.Text.Substring(0, 4);
lastNum = resolutionSelect.Text.Substring(Math.Max(0, resolutionSelect.Text.Length - 4));
// Removes any spaces from the above strings.
firstNum = firstNum.Replace(" ", "");
lastNum = lastNum.Replace(" ", "");
// Loads the Application Settings XML file
System.Xml.XmlDocument appConfigXML = new System.Xml.XmlDocument();
System.Xml.XmlDocument serConfigXML = new System.Xml.XmlDocument();
appConfigXML.Load(Game._path + "\\Content\\ApplicationSettings.xml");
serConfigXML.Load(Game._path + "\\Content\\ServiceSettings.xml");
// Sets the XML attributes to the current values of the editor
appConfigXML.SelectSingleNode("//ScreenTitle").InnerText = windowTitleBox.Text;
appConfigXML.SelectSingleNode("//FullScreen").InnerText = isFullScreen.Text;
appConfigXML.SelectSingleNode("//ScreenWidth").InnerText = Convert.ToString(firstNum);
appConfigXML.SelectSingleNode("//ScreenHeight").InnerText = Convert.ToString(lastNum);
// Saves the Application Settings XML file
appConfigXML.Save(Game._path + "\\Content\\ApplicationSettings.xml");
serConfigXML.Save(Game._path + "\\Content\\ServiceSettings.xml");
MessageBox.Show("Reload Application for changes to take effect");
System.Diagnostics.Process.Start(Game._path + @"\\Devoxelation.exe");
Application.Exit();
}
示例5: ChangeDFSXMLSlaveList
public static void ChangeDFSXMLSlaveList(string dfspath, string newSlavelist)
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(dfspath);
System.Xml.XmlNode node = doc.SelectSingleNode("//SlaveList");
node.InnerText = newSlavelist;
doc.Save(dfspath);
}
示例6: SetSetting
public static void SetSetting(string path, string key, string value)
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(path);
System.Xml.XmlNode node = doc.SelectSingleNode("settings/" + key);
node.InnerText = value;
doc.Save(path);
}
示例7: ComprobantesGridView_RowCommand
protected void ComprobantesGridView_RowCommand(object sender, GridViewCommandEventArgs e)
{
FeaEntidades.InterFacturas.lote_comprobantes lote = new FeaEntidades.InterFacturas.lote_comprobantes();
System.Xml.Serialization.XmlSerializer x;
int item = Convert.ToInt32(e.CommandArgument);
List<Entidades.Comprobante> lista = (List<Entidades.Comprobante>)ViewState["Comprobantes"];
Entidades.Comprobante comprobante = lista[item];
switch (e.CommandName)
{
case "Seleccionar":
Session["ComprobanteATratar"] = new Entidades.ComprobanteATratar(Entidades.Enum.TratamientoComprobante.Consulta, comprobante);
string script = "window.open('/ComprobanteConsulta.aspx', '');";
ScriptManager.RegisterStartupScript(this, typeof(Page), "popup", script, true);
break;
case "XML":
////Generar Lote
//lote = GenerarLote(false);
////Grabar en base de datos
//RN.Comprobante c = new RN.Comprobante();
//lote.cabecera_lote.DestinoComprobante = "ITF";
//lote.comprobante[0].cabecera.informacion_comprobante.Observacion = "";
//c.Registrar(lote, null, "ITF", ((Entidades.Sesion)Session["Sesion"]));
x = new System.Xml.Serialization.XmlSerializer(lote.GetType());
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append(comprobante.Cuit);
sb.Append("-");
sb.Append(comprobante.NroPuntoVta.ToString("0000"));
sb.Append("-");
sb.Append(comprobante.TipoComprobante.Id.ToString("00"));
sb.Append("-");
sb.Append(comprobante.Nro.ToString("00000000"));
sb.Append(".xml");
//System.IO.MemoryStream m = new System.IO.MemoryStream();
//System.IO.StreamWriter sw = new System.IO.StreamWriter(m);
//sw.Flush();
//System.Xml.XmlWriter writerdememoria = new System.Xml.XmlTextWriter(m, System.Text.Encoding.GetEncoding("ISO-8859-1"));
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
xmlDoc.LoadXml(comprobante.Request);
xmlDoc.Save(Server.MapPath(@"~/Temp/" + sb.ToString()));
//x.Serialize(writerdememoria, xmlDoc);
//m.Seek(0, System.IO.SeekOrigin.Begin);
//Descarga directa del XML
//System.IO.FileStream fs = new System.IO.FileStream(Server.MapPath(@"~/Temp/" + sb.ToString()), System.IO.FileMode.Create);
//m.WriteTo(fs);
//fs.Close();
Server.Transfer("~/DescargaTemporarios.aspx?archivo=" + sb.ToString(), false);
break;
default:
break;
}
}
示例8: Execute
public override bool Execute()
{
var originalFileXml = new System.Xml.XmlDocument();
originalFileXml.Load(Source.ItemSpec);
using (var xmlTransform = new XmlTransformation(Transform.ItemSpec))
{
if (xmlTransform.Apply(originalFileXml) == false)
return false;
originalFileXml.Save(Destination.ItemSpec);
}
return true;
}
示例9: ChangeSetting
internal static void ChangeSetting(string name, string value)
{
string configFileName = System.Windows.Forms.Application.ExecutablePath + ".config";
var doc = new System.Xml.XmlDocument();
doc.Load(configFileName);
string configString =
@"configuration/applicationSettings/Script_Text_Editor.Properties.Settings/setting[@name='"
+ name + "']/value";
System.Xml.XmlNode configNode = doc.SelectSingleNode(configString);
if (configNode != null)
{
configNode.InnerText = value;
doc.Save(configFileName);
// 刷新应用程序设置
Properties.Settings.Default.Reload();
}
}
示例10: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
try
{
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
string strRoot = Server.MapPath("/");
xmlDoc.LoadXml(txtEditor.Text);
xmlDoc.Save(strRoot + "XML\\QuanLyBanner.xml");
lbStatus.ForeColor = System.Drawing.Color.Blue;
lbStatus.Text = "Update thành công!";
}
catch (Exception exp)
{
lbStatus.ForeColor = System.Drawing.Color.Red;
lbStatus.Text = "Lỗi! Không thể update:";
}
}
示例11: Patch
public bool Patch() {
string home = System.Web.HttpRuntime.AppDomainAppPath;
System.IO.DirectoryInfo folder = new System.IO.DirectoryInfo(home);
if (folder.Exists)
{
string wildcard = "config." + this.GetEnvironment().ToString() + ".*.xml";
System.IO.FileInfo[] files = folder.GetFiles(wildcard);
System.Collections.Generic.List<string> section = new System.Collections.Generic.List<string>();
string webConfigFilename = System.IO.Path.Combine(home, "Web.config");
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
xmlDoc.Load(webConfigFilename);
bool changed = false;
foreach (System.IO.FileInfo file in files)
{
string webConfigSectionFilename = System.IO.Path.Combine(home, file.Name);
string[] filename = file.Name.Split('.');
for (int i = 2; i < filename.Length-1; i++)
{
section.Add(filename[i]);
}
System.Xml.XmlDocument xmlDocSection = new System.Xml.XmlDocument();
xmlDocSection.Load(webConfigSectionFilename);
string xPath = System.String.Join("/", section);
System.Xml.XmlNode node = xmlDoc.SelectSingleNode(xPath);
if (node != null && node.InnerXml != xmlDocSection.ChildNodes[1].InnerXml) {
node.InnerXml = xmlDocSection.ChildNodes[1].InnerXml;
changed = true;
}
}
if (changed)
{
xmlDoc.Save(webConfigFilename);
}
}
return true;
}
示例12: AddOrUpdate
/// <summary>
/// WinForm更新App.config中,key对应的value,没有则添加
/// </summary>
/// <param name="appKey">key</param>
/// <param name="appValue">value</param>
public static void AddOrUpdate(string appKey, string appValue)
{
var xDoc = new System.Xml.XmlDocument();
xDoc.Load(System.Windows.Forms.Application.ExecutablePath + ".config");
var xNode = xDoc.SelectSingleNode("//appSettings");
if (xNode != null)
{
var xElem1 = (System.Xml.XmlElement)xNode.SelectSingleNode("//add[@key='" + appKey + "']");
if (xElem1 != null) xElem1.SetAttribute("value", appValue);
else
{
var xElem2 = xDoc.CreateElement("add");
xElem2.SetAttribute("key", appKey);
xElem2.SetAttribute("value", appValue);
xNode.AppendChild(xElem2);
}
}
xDoc.Save(System.Windows.Forms.Application.ExecutablePath + ".config");
}
示例13: SetValue
/// <summary>
/// 根据Key修改Value
/// </summary>
/// <param name="key">要修改的Key</param>
/// <param name="value">要修改为的值</param>
public static void SetValue(string key, string value)
{
System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
xDoc.Load(HttpContext.Current.Server.MapPath("/XmlConfig/Config.xml"));
System.Xml.XmlNode xNode;
System.Xml.XmlElement xElem1;
System.Xml.XmlElement xElem2;
xNode = xDoc.SelectSingleNode("//appSettings");
xElem1 = (System.Xml.XmlElement)xNode.SelectSingleNode("//add[@key='" + key + "']");
if (xElem1 != null) xElem1.SetAttribute("value", value);
else
{
xElem2 = xDoc.CreateElement("add");
xElem2.SetAttribute("key", key);
xElem2.SetAttribute("value", value);
xNode.AppendChild(xElem2);
}
xDoc.Save(HttpContext.Current.Server.MapPath("/XmlConfig/Config.xml"));
}
示例14: SaveDocument
public static void SaveDocument(System.Xml.XmlDocument origDoc, System.IO.Stream strm, bool bDoReplace)
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
if (bDoReplace)
doc.LoadXml(origDoc.OuterXml.Replace("xmlns=\"\"", ""));
using (System.Xml.XmlTextWriter xtw = new System.Xml.XmlTextWriter(strm, System.Text.Encoding.UTF8))
{
xtw.Formatting = System.Xml.Formatting.Indented; // if you want it indented
xtw.Indentation = 4;
xtw.IndentChar = ' ';
doc.Save(xtw);
xtw.Flush();
xtw.Close();
} // End Using xtw
doc = null;
}
示例15: SetValue
public void SetValue(string AppKey, string AppValue)
{
System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
xDoc.Load(System.Windows.Forms.Application.ExecutablePath + ".config");
System.Xml.XmlNode xNode;
System.Xml.XmlElement xElem1;
System.Xml.XmlElement xElem2;
xNode = xDoc.SelectSingleNode("//appSettings");
xElem1 = (System.Xml.XmlElement)xNode.SelectSingleNode("//add[@key='" + AppKey + "']");
if (xElem1 != null) xElem1.SetAttribute("value", AppValue);
else
{
xElem2 = xDoc.CreateElement("add");
xElem2.SetAttribute("key", AppKey);
xElem2.SetAttribute("value", AppValue);
xNode.AppendChild(xElem2);
}
xDoc.Save(System.Windows.Forms.Application.ExecutablePath + ".config");
}