本文整理汇总了C#中System.Xml.XmlDocument类的典型用法代码示例。如果您正苦于以下问题:C# XmlDocument类的具体用法?C# XmlDocument怎么用?C# XmlDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlDocument类属于System.Xml命名空间,在下文中一共展示了XmlDocument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WMIBMySQL
public WMIBMySQL()
{
string file = Variables.ConfigurationDirectory + Path.DirectorySeparatorChar + "unwrittensql.xml";
Core.RecoverFile(file);
if (File.Exists(file))
{
Syslog.WarningLog("There is a mysql dump file from previous run containing mysql rows that were never successfuly inserted, trying to recover them");
XmlDocument document = new XmlDocument();
using (TextReader sr = new StreamReader(file))
{
document.Load(sr);
using (XmlNodeReader reader = new XmlNodeReader(document.DocumentElement))
{
XmlSerializer xs = new XmlSerializer(typeof(Unwritten));
Unwritten un = (Unwritten)xs.Deserialize(reader);
lock (unwritten.PendingRows)
{
unwritten.PendingRows.AddRange(un.PendingRows);
}
}
}
}
Thread reco = new Thread(Exec) {Name = "MySQL/Recovery"};
Core.ThreadManager.RegisterThread(reco);
reco.Start();
}
示例2: Save
public void Save(string path)
{
XmlDocument doc = new XmlDocument();
XmlElement root = doc.CreateElement("Resources");
doc.AppendChild(root);
XmlElement sheetsElem = doc.CreateElement("SpriteSheets");
foreach (KeyValuePair<string, SpriteSheet> pair in SpriteSheets)
{
XmlElement elem = doc.CreateElement(pair.Key);
pair.Value.Save(doc, elem);
sheetsElem.AppendChild(elem);
}
root.AppendChild(sheetsElem);
XmlElement spritesElem = doc.CreateElement("Sprites");
foreach (KeyValuePair<string, Sprite> pair in Sprites)
{
XmlElement elem = doc.CreateElement(pair.Key);
pair.Value.Save(doc, elem);
spritesElem.AppendChild(elem);
}
root.AppendChild(spritesElem);
XmlElement animsElem = doc.CreateElement("Animations");
foreach (KeyValuePair<string, Animation> pair in Animations)
{
XmlElement elem = doc.CreateElement(pair.Key);
pair.Value.Save(doc, elem);
animsElem.AppendChild(elem);
}
root.AppendChild(animsElem);
doc.Save(path);
}
示例3: Page_Load
private void Page_Load(object sender, EventArgs e)
{
XmlDocument configDoc = new XmlDocument();
configDoc.Load(Server.MapPath(Configuration.ConfigFile));
Configuration configuration = new Configuration(configDoc);
treeNavigator.ContentFile = configuration.ExamplesDataFile;
}
示例4: New
/// <summary>
/// Load the style from assmebly resource.
/// </summary>
public virtual void New()
{
Assembly ass = Assembly.GetExecutingAssembly();
Stream str = ass.GetManifestResourceStream("AODL.Resources.OD.manifest.xml");
this.Manifest = new XmlDocument();
this.Manifest.Load(str);
}
示例5: SetXpdlCache
/// <summary>
/// 设置流程文件缓存
/// </summary>
/// <param name="processGUID"></param>
/// <param name="xmlDoc"></param>
/// <returns></returns>
internal static XmlDocument SetXpdlCache(string processGUID, string version, XmlDocument xmlDoc)
{
var str = processGUID + version;
var strMD5 = MD5Helper.GetMD5(str);
return _xpdlCache.GetOrAdd(strMD5, xmlDoc);
}
示例6: CreateMapping
public override object[] CreateMapping(params object[] initParams)
{
XmlDocument document = (XmlDocument) initParams[0];
string str = (string) initParams[1];
DataSet mappingSet = this.GetMappingSet();
XmlDocument indexesDoc = new XmlDocument();
indexesDoc.Load(Path.Combine(str, "indexes.xml"));
foreach (XmlNode node in document.DocumentElement.SelectNodes("//type"))
{
DataRow row = mappingSet.Tables["types"].NewRow();
int mappedTypeId = int.Parse(node.Attributes["mappedTypeId"].Value);
int num2 = int.Parse(node.Attributes["selectedTypeId"].Value);
row["MappedTypeId"] = mappedTypeId;
row["SelectedTypeId"] = num2;
if (num2 == 0)
{
XmlNode node2 = indexesDoc.SelectSingleNode("//type[typeId[text()='" + mappedTypeId + "']]");
row["TypeName"] = node2.SelectSingleNode("typeName").InnerText;
row["Remark"] = node2.SelectSingleNode("remark").InnerText;
}
mappingSet.Tables["types"].Rows.Add(row);
XmlNodeList attributeNodeList = node.SelectNodes("attributes/attribute");
this.MappingAttributes(mappedTypeId, mappingSet, attributeNodeList, indexesDoc, str);
}
mappingSet.AcceptChanges();
return new object[] { mappingSet };
}
示例7: saveXml
private void saveXml()
{
string error = String.Empty;
XmlDocument modifiedXml = new XmlDocument();
modifiedXml.LoadXml(txtXml.Text);
pageNode.SetPersonalizationFromXml(HttpContext.Current, modifiedXml, out error);
}
示例8: LoadAll
internal static IList<Test> LoadAll()
{
var file = new FileInfo("tests.xml");
if (!file.Exists)
return new Test[0];
XmlDocument xml = new XmlDocument();
using (var fs = file.OpenRead())
xml.Load(fs);
var ret = new List<Test>();
foreach (XmlNode node in xml.SelectNodes("/Tests/*"))
{
var n = node.SelectSingleNode("./Type");
if (n == null)
throw new InvalidOperationException("Test Type must be informed.");
var typeName = n.InnerText;
var type = FindType(typeName);
if (type == null)
throw new InvalidOperationException(string.Format("'{0}' is not a valid Test.", typeName));
var obj = (Test)Activator.CreateInstance(type);
node.ToEntity(obj);
ret.Add(obj);
}
return ret;
}
示例9: UpdateSagaXMLFile
public static string UpdateSagaXMLFile(ref DataTable _XMLDt, string XMLpath)
{
try
{
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(XMLpath);
XmlNode xmlnode = xmldoc.DocumentElement.ChildNodes[0];
xmlnode["ODBCDriverName"].InnerText = _XMLDt.Rows[0]["ODBCDriverName"].ToString();
xmlnode["HostName"].InnerText = _XMLDt.Rows[0]["HostName"].ToString();
xmlnode["ServerName"].InnerText = _XMLDt.Rows[0]["ServerName"].ToString();
xmlnode["ServiceName"].InnerText = _XMLDt.Rows[0]["ServiceName"].ToString();
xmlnode["Protocol"].InnerText = _XMLDt.Rows[0]["Protocol"].ToString();
xmlnode["DatabaseName"].InnerText = _XMLDt.Rows[0]["DatabaseName"].ToString();
xmlnode["UserId"].InnerText = _XMLDt.Rows[0]["UserId"].ToString();
xmlnode["Password"].InnerText = _XMLDt.Rows[0]["Password"].ToString();
xmlnode["ClientLocale"].InnerText = _XMLDt.Rows[0]["ClientLocale"].ToString();
xmlnode["DatabaseLocale"].InnerText = _XMLDt.Rows[0]["DatabaseLocale"].ToString();
xmldoc.Save(XMLpath);
return "";
}
catch (Exception err)
{
return err.Message;
}
}
示例10: LoadXml
/// <summary>
/// loads a xml from the web server
/// </summary>
/// <param name="_url">URL of the XML file</param>
/// <returns>A XmlDocument object of the XML file</returns>
public static XmlDocument LoadXml(string _url)
{
var xmlDoc = new XmlDocument();
try
{
while (Helper.pingForum("forum.mods.de", 10000) == false)
{
Console.WriteLine("Can't reach forum.mods.de right now, try again in 15 seconds...");
System.Threading.Thread.Sleep(15000);
}
xmlDoc.Load(_url);
}
catch (XmlException)
{
while (Helper.pingForum("forum.mods.de", 100000) == false)
{
Console.WriteLine("Can't reach forum.mods.de right now, try again in 15 seconds...");
System.Threading.Thread.Sleep(15000);
}
WebClient client = new WebClient(); ;
Stream stream = client.OpenRead(_url);
StreamReader reader = new StreamReader(stream);
string content = reader.ReadToEnd();
content = RemoveTroublesomeCharacters(content);
xmlDoc.LoadXml(content);
}
return xmlDoc;
}
示例11: GeoIP
public GeoIP()
{
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://freegeoip.net/xml/");
request.Proxy = null;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseString = reader.ReadToEnd();
reader.Close();
dataStream.Close();
response.Close();
XmlDocument doc = new XmlDocument();
doc.LoadXml(responseString);
WANIP = doc.SelectSingleNode("Response//Ip").InnerXml.ToString();
Country = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//CountryName").InnerXml.ToString())) ? doc.SelectSingleNode("Response//CountryName").InnerXml.ToString() : "Unknown";
CountryCode = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//CountryCode").InnerXml.ToString())) ? doc.SelectSingleNode("Response//CountryCode").InnerXml.ToString() : "-";
Region = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//RegionName").InnerXml.ToString())) ? doc.SelectSingleNode("Response//RegionName").InnerXml.ToString() : "Unknown";
City = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//City").InnerXml.ToString())) ? doc.SelectSingleNode("Response//City").InnerXml.ToString() : "Unknown";
}
catch
{
WANIP = "-";
Country = "Unknown";
CountryCode = "-";
Region = "Unknown";
City = "Unknown";
}
}
示例12: StudyDeleteRecord
public StudyDeleteRecord(
String _studyInstanceUid_
,DateTime _timestamp_
,String _serverPartitionAE_
,ServerEntityKey _filesystemKey_
,String _backupPath_
,String _reason_
,String _accessionNumber_
,String _patientId_
,String _patientsName_
,String _studyId_
,String _studyDescription_
,String _studyDate_
,String _studyTime_
,XmlDocument _archiveInfo_
,String _extendedInfo_
):base("StudyDeleteRecord")
{
StudyInstanceUid = _studyInstanceUid_;
Timestamp = _timestamp_;
ServerPartitionAE = _serverPartitionAE_;
FilesystemKey = _filesystemKey_;
BackupPath = _backupPath_;
Reason = _reason_;
AccessionNumber = _accessionNumber_;
PatientId = _patientId_;
PatientsName = _patientsName_;
StudyId = _studyId_;
StudyDescription = _studyDescription_;
StudyDate = _studyDate_;
StudyTime = _studyTime_;
ArchiveInfo = _archiveInfo_;
ExtendedInfo = _extendedInfo_;
}
示例13: DlgTips_Load
private void DlgTips_Load(object sender, EventArgs e)
{
try
{
string strxml = "";
using (StreamReader streamReader = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("Johnny.Kaixin.WinUI.Resources.Versions.config")))
{
strxml = streamReader.ReadToEnd();
}
XmlDocument objXmlDoc = new XmlDocument();
objXmlDoc.LoadXml(strxml);
if (objXmlDoc == null)
return;
DataView dv = GetData(objXmlDoc, "ZrAssistant/Versions");
for (int ix = 0; ix < dv.Table.Rows.Count; ix++)
{
_versionList.Add(dv.Table.Rows[ix][0].ToString(), dv.Table.Rows[ix][1].ToString());
cmbVersion.Items.Add(dv.Table.Rows[ix][0].ToString());
}
chkNeverDisplay.Checked = Properties.Settings.Default.NeverDisplay;
cmbVersion.SelectedIndex = 0;
SetTextValue();
btnOk.Select();
}
catch (Exception ex)
{
Program.ShowMessageBox("DlgTips", ex);
}
}
示例14: AddXmlNodes
//Appends the any xml file/folder nodes onto the folder
private void AddXmlNodes(FolderCompareObject folder, int numOfPaths, XmlDocument xmlDoc)
{
List<XMLCompareObject> xmlObjList = new List<XMLCompareObject>();
List<string> xmlFolderList = new List<string>();
for (int i = 0; i < numOfPaths; i++)
{
string path = Path.Combine(folder.GetSmartParentPath(i), folder.Name);
if (Directory.Exists(path))
{
DirectoryInfo dirInfo = new DirectoryInfo(path);
FileInfo[] fileList = dirInfo.GetFiles();
DirectoryInfo[] dirInfoList = dirInfo.GetDirectories();
string xmlPath = Path.Combine(path, CommonXMLConstants.MetadataPath);
if (!File.Exists(xmlPath))
continue;
CommonMethods.LoadXML(ref xmlDoc, xmlPath);
xmlObjList = GetAllFilesInXML(xmlDoc);
xmlFolderList = GetAllFoldersInXML(xmlDoc);
RemoveSimilarFiles(xmlObjList, fileList);
RemoveSimilarFolders(xmlFolderList, dirInfoList);
}
AddFileToChild(xmlObjList, folder, i, numOfPaths);
AddFolderToChild(xmlFolderList, folder, i, numOfPaths);
xmlObjList.Clear();
xmlFolderList.Clear();
}
}
示例15: SetValue
/// <summary>
/// Define o valor de uma configuração
/// </summary>
/// <param name="file">Caminho do arquivo (ex: c:\program.exe.config)</param>
/// <param name="key">Nome da configuração</param>
/// <param name="value">Valor a ser salvo</param>
/// <returns></returns>
public static bool SetValue(string file, string key, string value)
{
var fileDocument = new XmlDocument();
fileDocument.Load(file);
var nodes = fileDocument.GetElementsByTagName(AddElementName);
if (nodes.Count == 0)
{
return false;
}
for (var i = 0; i < nodes.Count; i++)
{
var node = nodes.Item(i);
if (node == null || node.Attributes == null || node.Attributes.GetNamedItem(KeyPropertyName) == null)
continue;
if (node.Attributes.GetNamedItem(KeyPropertyName).Value == key)
{
node.Attributes.GetNamedItem(ValuePropertyName).Value = value;
}
}
var writer = new XmlTextWriter(file, null) { Formatting = Formatting.Indented };
fileDocument.WriteTo(writer);
writer.Flush();
writer.Close();
return true;
}