我有以下简单的 XML 文件:
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit http://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>False</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>E:\PublishTest</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
</PropertyGroup>
</Project>
我试图通过执行以下操作来更改其中一个元素的值:
XmlDocument xDoc = new XmlDocument();
xDoc.Load(fullPathToPortalPublishSettings);
// Change the publish url to be the one we want
var a = xDoc.SelectNodes("/Project/PropertyGroup");
但它总是会爆炸。我已经删除了 XML 文件顶部的注释,我试过了/Project
,只是Project
,但我似乎无法理解出了什么问题。我看过其他帖子,但看不到我的问题。任何的想法?谢谢!