使用 nant 将属性添加到 xml 节点
有没有办法使用 nant 将属性添加到 xml 节点(我有其 xpath)? 尝试了 xmlpoke,但看起来它只能更新现有属性。
谢谢。
Is there a way to add an attribute to an xml node (which I have the xpath of) using nant?
Tried xmlpoke but it looks like it can only update existing attributes.
thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
XmlPoke 肯定不起作用,因为 xpath 必须首先匹配某些内容才能替换它。
我知道执行此操作的唯一方法是创建您自己的任务,该任务允许您将数据添加到 xml 文件。 这些新任务可以单独构建并通过将 dll 复制到 NAnt\bin 文件夹中或直接从构建文件扩展 NAnt 来添加到 NAnt
。 sourceforge.net/release/0.85/help/tasks/script.html" rel="nofollow noreferrer">
如果您碰巧使此任务足够通用,那么尝试将其提交到 NAntContrib< 可能会很好/a> 所以每个人都受益。
XmlPoke will definitely not work because the xpath must match something in the first place to be able to replace it.
The only way I know of doing this is to create your own task that would allow you to add data to an xml file. These new tasks can either be build separately and added to NAnt by copying dlls into NAnt\bin folder, or by extending NAnt directly from your build files
The information to get you started is found on <script/> Task
If you happen to make this task generic enough, it might be good to try to submit it to NAntContrib so everyone benefits.
我最近做了类似的东西。 这是用于插入节点,但应该很容易更改。
I made something similar recently. This is for inserting nodes, but should be easily changed.