首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用CakeBuild XMLPoke更改节点的内部文本值

使用CakeBuild XMLPoke更改节点的内部文本值
EN

Stack Overflow用户
提问于 2017-04-05 16:29:00
回答 1查看 932关注 0票数 4

我很难弄清楚如何使用Cake中的XmlPoke更改XML节点的内部文本值。我一直收到的错误是Error: Expression must evaluate to a node-set.

我的XML看起来像这样

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<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>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <publishUrl>This value must be set to your local path</publishUrl>
    <DeleteExistingFiles>False</DeleteExistingFiles>
  </PropertyGroup>
</Project>

我的build.cake看起来像这样

代码语言:javascript
复制
// Update the publish path in the pubxml
XmlPoke(publishProfile, "/Project/PropertyGroup/publishUrl/", buildPaths.PublishDirectory);

// The publishProfile is just the location of the XML file
// The buildPaths.PublishDirectory is the value I'm trying to set the inner text to
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-05 17:18:14

您还需要设置名称空间。如下所示:

代码语言:javascript
复制
// Update the publish path in the pubxml
XmlPoke(publishProfile,
    "/ns:Project/ns:PropertyGroup/ns:publishUrl",
    buildPaths.PublishDirectory,
    new XmlPokeSettings {
        Namespaces = new Dictionary<string, string> {
            { "ns", "http://schemas.microsoft.com/developer/msbuild/2003" }
        }
    });

此外,您还可能希望查看魔法块

票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43236781

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档