我加载一个XML文档:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("MyFile.xml");
Run Code Online (Sandbox Code Playgroud)
并创建一个新文档:
XmlDocument xmlDocSettings = new XmlDocument();
XmlNode xmlDecl = xmlDocSettings.CreateNode(XmlNodeType.XmlDeclaration, "", "");
xmlDocSettings.AppendChild(xmlDecl);
XmlElement root = xmlDocSettings.CreateElement("", "Test", "");
root.SetAttribute("TestAttribute", "AttributeValue");
xmlDocSettings.AppendChild(root);
Run Code Online (Sandbox Code Playgroud)
现在,我想插入的内容xmlDoc来xmlDocSettings。我怎样才能做到这一点?
谢谢!
非常新手的问题.
我想覆盖我的WPF应用程序中的Main,所以如果我双击一个文件,它将被加载.我的主要功能是:
[STAThread]
static void Main(string[] args)
{
FileConvert.App app = new FileConvert.App();
app.InitializeComponent();
if (args.Length > 0)
{
Window1 wnd1 = (Window1)(app.MainWindow);
wnd1.SetProjectFile(args[0]);
}
app.Run();
Run Code Online (Sandbox Code Playgroud)
我的问题是wnd1为null.如何访问此窗口以便我可以将文件名传递给它?
谢谢!