本文整理汇总了C#中System.Xml.XmlDocument类的典型用法代码示例。如果您正苦于以下问题:C# System.Xml.XmlDocument类的具体用法?C# System.Xml.XmlDocument怎么用?C# System.Xml.XmlDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.Xml.XmlDocument类属于命名空间,在下文中一共展示了System.Xml.XmlDocument类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:eakova,项目名称:resizer,代码行数:27,代码来源:NativeDependencyManager.cs
示例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;
}
}
开发者ID:stavrossk,项目名称:Disc_Archiver_for_Meedio,代码行数:36,代码来源:IMDbLib.cs
示例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;
}
开发者ID:inickvel,项目名称:SqlCeToolbox,代码行数:25,代码来源:AboutDlg.cs
示例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);
}
开发者ID:sopindm,项目名称:bjeb,代码行数:7,代码来源:Xml.cs
示例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;
}
开发者ID:joshuaphendrix,项目名称:TurfWars,代码行数:32,代码来源:Service.asmx.cs
示例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;
}
开发者ID:JaspreetSawhney,项目名称:Jaspreet-HS-Dev,代码行数:27,代码来源:Header.Master.cs
示例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");
}
开发者ID:nickdevore,项目名称:CruiseControl.NET,代码行数:25,代码来源:CCnetDeploymentTests.cs
示例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();
}
开发者ID:poxet,项目名称:Rubicon-Reverse-Proxy,代码行数:26,代码来源:RedirectRuleManager.cs
示例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;
}
开发者ID:PrototypeAlpha,项目名称:LiveSplit,代码行数:31,代码来源:LiveSplitImageSourceFactory.cs
示例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);
}
开发者ID:Jarolim,项目名称:AllMyHomeworkForTelerikAcademy,代码行数:28,代码来源:SimpleSearch.cs
示例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();
}
开发者ID:BrookHuang,项目名称:XYFrame,代码行数:25,代码来源:HttpModule.cs
示例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;
}
开发者ID:lujinlong,项目名称:Apq,代码行数:11,代码来源:XmlDocument.cs
示例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("インポートに失敗しました。");
}
}
}
开发者ID:nico-lab,项目名称:niconama-ocv,代码行数:29,代码来源:Importer.cs
示例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;
}
}
}
开发者ID:aromero78,项目名称:Total-CMS,代码行数:26,代码来源:YUIHandler.cs
示例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." );
}
开发者ID:And-G,项目名称:Magellan,代码行数:35,代码来源:Boot.cs
示例16: 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();
}
}
开发者ID:BGCX262,项目名称:zynchronyze-svn-to-git,代码行数:32,代码来源:Form1.cs
示例17: ListQueues
public List<Queue> ListQueues(
string prefix = null,
bool IncludeMetadata = false,
int timeoutSeconds = 0,
Guid? xmsclientrequestId = null)
{
List<Queue> lQueues = new List<Queue>();
string strNextMarker = null;
do
{
string sRet = Internal.InternalMethods.ListQueues(UseHTTPS, SharedKey, AccountName, prefix, strNextMarker,
IncludeMetadata: IncludeMetadata, timeoutSeconds: timeoutSeconds, xmsclientrequestId: xmsclientrequestId);
//Microsoft.SqlServer.Server.SqlContext.Pipe.Send("After Internal.InternalMethods.ListQueues = " + sRet);
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
using (System.IO.StringReader sr = new System.IO.StringReader(sRet))
{
doc.Load(sr);
}
foreach (System.Xml.XmlNode node in doc.SelectNodes("EnumerationResults/Queues/Queue"))
{
lQueues.Add(Queue.ParseFromXmlNode(this, node));
};
strNextMarker = doc.SelectSingleNode("EnumerationResults/NextMarker").InnerText;
//Microsoft.SqlServer.Server.SqlContext.Pipe.Send("strNextMarker == " + strNextMarker);
} while (!string.IsNullOrEmpty(strNextMarker));
return lQueues;
}
开发者ID:DomG4,项目名称:sqlservertoazure,代码行数:34,代码来源:AzureQueueService.cs
示例18: DeserializeBannerTestSuccessfull
public void DeserializeBannerTestSuccessfull()
{
string content =
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?><Banners><Banner><id>605881</id><BannerPath>fanart/original/83462-18.jpg</BannerPath><BannerType>fanart</BannerType><BannerType2>1920x1080</BannerType2><Colors>|217,177,118|59,40,68|214,192,205|</Colors><Language>de</Language><Rating>9.6765</Rating><RatingCount>34</RatingCount><SeriesName>false</SeriesName><ThumbnailPath>_cache/fanart/original/83462-18.jpg</ThumbnailPath><VignettePath>fanart/vignette/83462-18.jpg</VignettePath></Banner></Banners>";
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.LoadXml(content);
System.Xml.XmlNode bannersNode = doc.ChildNodes[1];
System.Xml.XmlNode bannerNode = bannersNode.ChildNodes[0];
Banner target = new Banner();
target.Deserialize(bannerNode);
Assert.Equal(605881, target.Id);
Assert.Equal("fanart/original/83462-18.jpg", target.BannerPath);
Assert.Equal(BannerTyp.fanart, target.Type);
Assert.Equal("1920x1080", target.Dimension);
Assert.Equal("|217,177,118|59,40,68|214,192,205|", target.Color);
Assert.Equal("de", target.Language);
Assert.Equal(9.6765, target.Rating);
Assert.Equal(34, target.RatingCount);
Assert.Equal(false, target.SeriesName);
Assert.Equal("_cache/fanart/original/83462-18.jpg", target.ThumbnailPath);
Assert.Equal("fanart/vignette/83462-18.jpg", target.VignettePath);
}
开发者ID:StefanZi,项目名称:TheTVDBApi,代码行数:26,代码来源:BannerTest.cs
示例19: Main
static void Main() {
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load("../../XmlFile1.xml");
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new DekiPublishTestForm());
}
开发者ID:heran,项目名称:DekiWiki,代码行数:7,代码来源:Program.cs
示例20: 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;
}
开发者ID:faze79,项目名称:rmo-rugbymania,代码行数:32,代码来源:TabPartite.cs
注:本文中的System.Xml.XmlDocument类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论