本文整理汇总了C#中System.Xml.XmlDocument类的典型用法代码示例。如果您正苦于以下问题:C# System.Xml.XmlDocument类的具体用法?C# System.Xml.XmlDocument怎么用?C# System.Xml.XmlDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.Xml.XmlDocument类属于命名空间,在下文中一共展示了System.Xml.XmlDocument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnsureLoaded
public void EnsureLoaded(Assembly a)
{
if (assembliesProcessed.Contains(a.FullName)) return;
Stopwatch sw = new Stopwatch();
sw.Start();
try {
object[] attrs = a.GetCustomAttributes(typeof(Util.NativeDependenciesAttribute), true);
if (attrs.Length == 0) return;
var attr = attrs[0] as Util.NativeDependenciesAttribute;
string shortName = a.GetName().Name;
string resourceName = shortName + "." + attr.Value;
var info = a.GetManifestResourceInfo(resourceName);
if (info == null) { this.AcceptIssue(new Issues.Issue("Plugin error - failed to find embedded resource " + resourceName, Issues.IssueSeverity.Error)); return; }
using (Stream s = a.GetManifestResourceStream(resourceName)){
var x = new System.Xml.XmlDocument();
x.Load(s);
var n = new Node(x.DocumentElement, this);
EnsureLoaded(n, shortName,sw);
}
} finally {
assembliesProcessed.Add(a.FullName);
}
}
示例2: ReadGoofs
/// <summary>
/// Retrieves list of goofs from specified xml file
/// </summary>
/// <param name="xmlPath">path of xml file to read from</param>
public IList<IIMDbGoof> ReadGoofs(
string xmlPath)
{
try
{
List<IIMDbGoof> goofs = new List<IIMDbGoof>();
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(xmlPath);
System.Xml.XmlNodeList goofList = doc.SelectNodes("/Goofs/Goof");
if (goofList != null)
foreach (System.Xml.XmlNode goofNode in goofList)
{
if (goofNode["Category"] != null
&& goofNode["Category"].InnerText != null
&& goofNode["Category"].InnerText.Trim() != ""
&& goofNode["Description"] != null
&& goofNode["Description"].InnerText != null
&& goofNode["Description"].InnerText.Trim() != "")
{
IMDbGoof goof = new IMDbGoof();
goof.Category = goofNode["Category"].InnerText;
goof.Description = goofNode["Description"].InnerText;
goofs.Add(goof);
}
}
return goofs;
}
catch (Exception ex)
{
throw ex;
}
}
示例3: CheckVersion
private bool CheckVersion(string lookingFor)
{
try
{
using (var wc = new System.Net.WebClient())
{
var xDoc = new System.Xml.XmlDocument();
xDoc.Load(@"http://www.sqlcompact.dk/SqlCeToolboxVersions.xml");
string newVersion = xDoc.DocumentElement.Attributes[lookingFor].Value;
Version vN = new Version(newVersion);
if (vN > Assembly.GetExecutingAssembly().GetName().Version)
{
return true;
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
return false;
}
示例4: read
public static Xml read(Connection connection)
{
System.Xml.XmlDocument document = new System.Xml.XmlDocument();
document.LoadXml(connection.stream.readString());
return new Xml(document);
}
示例5: getClaims
public System.Xml.XmlDocument getClaims()
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
System.Xml.XmlElement claims = doc.CreateElement("claims");
foreach(TurfWarsGame.Claim c in TurfWars.Global.game.getClaims())
{
System.Xml.XmlElement claim = doc.CreateElement("claim");
System.Xml.XmlElement owners = doc.CreateElement("owners");
foreach (string u in c.getOwners().Keys)
{
System.Xml.XmlElement owner = doc.CreateElement("owner");
owner.SetAttribute("name", u);
owner.SetAttribute("share", c.getOwners()[u].ToString());
owners.AppendChild(owner);
}
System.Xml.XmlElement tile = doc.CreateElement("tile");
tile.SetAttribute("north",c.box.north.ToString());
tile.SetAttribute("south",c.box.south.ToString());
tile.SetAttribute("west", c.box.west.ToString());
tile.SetAttribute("east", c.box.east.ToString());
claim.AppendChild(owners);
claim.AppendChild(tile);
claims.AppendChild(claim);
}
doc.AppendChild(claims);
return doc;
}
示例6: HostIpToLocation
protected string HostIpToLocation()
{
string sourceIP = string.IsNullOrEmpty(Request.ServerVariables["HTTP_X_FORWARDED_FOR"])
? Request.ServerVariables["REMOTE_ADDR"]
: Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
string url = "http://api.ipinfodb.com/v2/ip_query.php?key={0}&ip={1}&timezone=true";
url = String.Format(url, "90d4f5e07ed75a6ed8ad13221d88140001aebf6730eec98978151d2a455d5e95", sourceIP);
HttpWebRequest httpWRequest = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse httpWResponse = (HttpWebResponse)httpWRequest.GetResponse();
System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
xdoc.Load(httpWResponse.GetResponseStream());
string city = "", state = "";
foreach (System.Xml.XmlNode x in xdoc.SelectSingleNode("Response").ChildNodes)
{
//Response.Write(x.Name + "<br>");
if (x.Name == "City") { city = x.InnerText + ", "; }
if (x.Name == "RegionName") { state = x.InnerText; }
}
return city + state;
}
示例7: TestForAdminPackageOfWebDashboardIsEmpty
public void TestForAdminPackageOfWebDashboardIsEmpty()
{
#if BUILD
string configFile = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), @"..\..\Project\Webdashboard\dashboard.config");
#else
string configFile = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), @"..\..\..\Webdashboard\dashboard.config");
#endif
Assert.IsTrue(System.IO.File.Exists(configFile), "Dashboard.config not found at {0}", configFile);
System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
xdoc.Load(configFile);
var adminPluginNode = xdoc.SelectSingleNode("/dashboard/plugins/farmPlugins/administrationPlugin");
Assert.IsNotNull(adminPluginNode, "Admin package configuration not found in dashboard.config at {0}", configFile);
var pwd = adminPluginNode.Attributes["password"];
Assert.IsNotNull(pwd, "password attribute not defined in admin packackage in dashboard.config at {0}", configFile);
Assert.AreEqual("", pwd.Value, "Password must be empty string, to force users to enter one. No default passwords allowed in distribution");
}
示例8: Load
public void Load()
{
var redirectRuleConfigFile = System.Configuration.ConfigurationManager.AppSettings["RedirectRuleConfigFile"];
if (System.IO.File.Exists(redirectRuleConfigFile))
{
var xmd = new System.Xml.XmlDocument();
xmd.Load(redirectRuleConfigFile);
var nodes = xmd.GetElementsByTagName("RedirectRule");
foreach (System.Xml.XmlElement xme in nodes)
{
var callingClient = IPAddress.Any; //Not yet supported "CallingClient"
var requestHost = xme.Attributes["RequestHost"].Value;
var requestPort = int.Parse(xme.Attributes["RequestPort"].Value);
var targetAddress = xme.Attributes["TargetAddress"].Value;
var targetPort = int.Parse(xme.Attributes["TargetPort"].Value);
Instance.Add(new RedirectRule(callingClient, requestHost, requestPort, IPAddress.Parse(targetAddress), targetPort), false);
}
}
//Append sample redirect rules
//Instance.Add(new RedirectRule(IPAddress.Any, null, 3001, IPAddress.Parse("127.0.0.1"), 3002), false);
//Instance.Add(new RedirectRule(IPAddress.Any, "ws1.test.com", 3003, IPAddress.Parse("127.0.0.1"), 3002), false);
//Save();
}
示例9: ShowConfiguration
public override bool ShowConfiguration(XElement config)
{
var dialog = new LiveSplitConfigurationDialog(config);
if (dialog.ShowDialog().GetValueOrDefault(false))
{
if (config.Parent.GetInt("cx") == 0 || config.Parent.GetInt("cy") == 0)
{
try
{
using (var layoutStream = System.IO.File.OpenRead(config.GetString("layoutpath")))
{
var xmlDoc = new System.Xml.XmlDocument();
xmlDoc.Load(layoutStream);
var parent = xmlDoc["Layout"];
var width = parent["VerticalWidth"];
config.Parent.SetInt("cx", int.Parse(width.InnerText));
var height = parent["VerticalHeight"];
config.Parent.SetInt("cy", int.Parse(height.InnerText)); //TODO Will break with horizontal
}
}
catch (Exception ex)
{
Log.Error(ex);
}
}
return true;
}
return false;
}
示例10: Main
static void Main()
{
var xmlSearch = new System.Xml.XmlDocument();
//select one of the above Query, Query1
xmlSearch.Load(Query1);
var query = xmlSearch.SelectSingleNode("/query");
var author = query[Author].GetText();
var title = query[Title].GetText();
var isbn = query[ISBN].GetText();
var dbContext = new BookstoreDbContext();
var queryLogEntry = new SearchLogEntry
{
Date = DateTime.Now,
QueryXml = query.OuterXml
};
var foundBooks = GenerateQuery(author, title, isbn, dbContext);
dbContext.SearchLog.Add(queryLogEntry);
dbContext.SaveChanges();
PrintResult(foundBooks);
}
示例11: Init
public void Init(HttpApplication context)
{
System.Xml.XmlDocument _document = new System.Xml.XmlDocument();
_document.Load(Xy.Tools.IO.File.foundConfigurationFile("App", Xy.AppSetting.FILE_EXT));
foreach (System.Xml.XmlNode _item in _document.GetElementsByTagName("Global")) {
string _className = _item.InnerText;
Type _tempCtonrlType = Type.GetType(_className, false, true);
IGlobal _tempGlobal;
if (_tempCtonrlType == null) {
System.Reflection.Assembly asm = System.Reflection.Assembly.Load(_className.Split(',')[0]);
_tempCtonrlType = asm.GetType(_className.Split(',')[1], false, true);
}
_tempGlobal = System.Activator.CreateInstance(_tempCtonrlType) as IGlobal;
if (_tempGlobal != null) {
global = _tempGlobal;
}
}
if (global == null) { global = new EmptyGlobal(); }
global.ApplicationInit(context);
context.BeginRequest += new EventHandler(context_BeginRequest);
context.Error += new EventHandler(context_Error);
context.EndRequest += new EventHandler(context_EndRequest);
_urlManager = URLManage.URLManager.GetInstance();
}
示例12: NewXmlDocument
/// <summary>
/// 新建
/// </summary>
/// <returns></returns>
public static System.Xml.XmlDocument NewXmlDocument()
{
System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
xd.LoadXml(@"<?xml version=""1.0"" encoding=""utf-8"" ?>
<Root/>");
return xd;
}
示例13: menuitem_Click
void menuitem_Click(object sender, EventArgs e)
{
System.Windows.Forms.OpenFileDialog of = new System.Windows.Forms.OpenFileDialog();
of.DefaultExt = ".xml";
of.Filter = "XMLファイル(*.xml)|*.xml";
if (of.ShowDialog((System.Windows.Forms.IWin32Window)_host.Win32WindowOwner) == System.Windows.Forms.DialogResult.OK) {
try {
System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
xdoc.Load(of.FileName);
// 擬似的に放送に接続した状態にする
_host.StartMockLive("lv0", System.IO.Path.GetFileNameWithoutExtension(of.FileName), DateTime.Now);
// ファイル内のコメントをホストに登録する
foreach (System.Xml.XmlNode node in xdoc.SelectNodes("packet/chat")) {
Hal.OpenCommentViewer.Control.OcvChat chat = new Hal.OpenCommentViewer.Control.OcvChat(node);
_host.InsertPluginChat(chat);
}
_host.ShowStatusMessage("インポートに成功しました。");
}catch(Exception ex){
NicoApiSharp.Logger.Default.LogException(ex);
_host.ShowStatusMessage("インポートに失敗しました。");
}
}
}
示例14: ProcessRequest
public void ProcessRequest(HttpContext context)
{
//write your handler implementation here.
string Obj = context.Request["object"];
if (!string.IsNullOrEmpty(Obj)) {
switch (Obj.ToLower()) {
case "dashboard":
string nodeType = context.Request["nodeType"];
switch (nodeType) {
case "RootNode":
Newtonsoft.Json.Linq.JObject ResultSet = new Newtonsoft.Json.Linq.JObject();
System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
xDoc.Load(context.Server.MapPath("~/Admin/Config/ApplicationSettings.xml"));
Newtonsoft.Json.Converters.XmlNodeConverter converter = new Newtonsoft.Json.Converters.XmlNodeConverter();
string OutputJSON = Newtonsoft.Json.JsonConvert.SerializeXmlNode(xDoc).Replace("@", string.Empty);
context.Response.Write(OutputJSON);
break;
default:
string[] TypeParts = nodeType.Split(',');
break;
}
break;
}
}
}
示例15: ImportProvince
public static void ImportProvince( string source, string target, ExportMode mode )
{
Console.WriteLine( "Opening source file \"{0}\"...", Path.GetFileName( source ) );
ProvinceList provinces = new ProvinceList();
FileStream stream = null;
try {
stream = new FileStream( source, FileMode.Open, FileAccess.Read, FileShare.Read );
if ( mode == ExportMode.XML ) {
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load( stream );
provinces.ReadFrom( doc );
}
else {
provinces.ReadFrom( new EU2.IO.CSVReader( stream ) );
}
}
finally {
if ( stream != null ) stream.Close();
}
Console.WriteLine( "Opening target file \"{0}\"...", Path.GetFileName( target ) );
EU2.Edit.File file = new EU2.Edit.File();
try {
file.ReadFrom( target );
}
catch ( EU2.Edit.InvalidFileFormatException ) {
Console.WriteLine( "The specified target file is not an EU2Map file, or is corrupt." );
return;
}
file.Provinces = provinces;
file.WriteTo( target );
Console.WriteLine( "Import successful." );
}