C#访问嵌入DLL的XML文件(代码示例)
时间:2011-03-18 来源:张浩华
using System;
using System.Xml;
using System.IO;
using System.Reflection;
using System.Resources;
namespace TestNAA
{
class Program
{
static void Main(string[] args)
{
string xmlNamespace = "Model"; //XML文件所在的命名空间
string xmlPath = "Model.StudentInfo.naa.xml"; //XML文件的路径( namespace + filename )
Assembly myAssembly = Assembly.Load(xmlNamespace);
Stream strm = myAssembly.GetManifestResourceStream(xmlPath);
//以下是XML操作部分 注释(略)
XmlDocument xd = new XmlDocument();
xd.Load(strm);
Console.WriteLine(xd.ChildNodes[1].Attributes["name"].Value);
Console.WriteLine(xd.ChildNodes[1].Attributes["table"].Value);
Console.Read();
}
}
}
相关阅读 更多 +










