{"issue":{"title":"Enable xmlpoke to replace nodes","user":{"login":"fhaag","id":1283543,"url":"https://api.github.com/users/fhaag","gravatar_id":"0a2026494464ac339c71a416d342d1d5","avatar_url":"https://secure.gravatar.com/avatar/0a2026494464ac339c71a416d342d1d5?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"created_at":"2011-12-24T10:26:35Z","milestone":null,"labels":[],"state":"open","updated_at":"2011-12-24T10:26:35Z","id":2652367,"html_url":"https://github.com/nant/nant/issues/14","pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"closed_at":null,"body":"The xmlpoke task can only replace the contents of a particular node. Imagine an Xml document like this:\r\n\r\n```xml\r\n<a>\r\n  <b key=\"x\"/>\r\n  <b key=\"y\"/>\r\n  <c key=\"u\"/>\r\n  <b key=\"z\"/>\r\n  <c key=\"v\"/>\r\n</a>\r\n```\r\n\r\nWith xmlpoke, it is not possible (as far as I can see) to replace <c key=\"u\"/> with <b key=\"u\"/>.\r\n\r\nProposed solution: Add a new \"replaceContents\" parameter to xmlpoke that defaults to \"true\". When set to \"false\", the node(s) designated by the XPath expression will be replaced, rather than its/their contents.\r\n\r\nPlease let me know if you consider this useful, and if such an extension is being worked on - otherwise, I might like to look into creating and submitting a patch ... though I suspect that adding the parameter and replacing line XmlPokeTask.cs:300 with something like\r\n\r\n```c#\r\nif (replaceContents) {\r\n  node.InnerXml = value;\r\n} else {\r\n  StringBuilder newInnerXml = new StringBuilder();\r\n  foreach (XmlNode currentNode in node.ParentNode.ChildNodes) {\r\n    if (currentNode == node) {\r\n      newInnerXml.Append(value);\r\n    } else {\r\n      newInnerXml.Append(currentNode.OuterXml);\r\n    }\r\n  }\r\n  node.ParentNode.InnerXml = newInnerXml.ToString();\r\n}\r\n```\r\n\r\nmight be all that's needed.\r\n\r\nThanks a lot!","number":14,"url":"https://api.github.com/repos/nant/nant/issues/14","comments":0,"assignee":null},"action":"opened"}