how to add or remove xml tags using xmlpoke in grunt plugin ?

Not applicable
 
Solved Solved
1 7 573
1 ACCEPTED SOLUTION

Not applicable

Great question @utsav. Xmlpoke plugin doesn't have that feature. However, you can try Grunt XMLstoke, which seems to augment the capabilities of Xmlpoke to remove XML nodes. Check out the following section to learn how to do so. https://www.npmjs.com/package/grunt-xmlstoke#example---deleting-nodes. If it works or not, please post back to continue the conversation. Happy coding.

View solution in original post

7 REPLIES 7

Not applicable

I am using grunt plugin to build deploy my api proxy. I have a scenario in which I have to add/remove virtualhost tag from my proxy. Can you please guide me on how to do that

Not applicable

Great question @utsav. Xmlpoke plugin doesn't have that feature. However, you can try Grunt XMLstoke, which seems to augment the capabilities of Xmlpoke to remove XML nodes. Check out the following section to learn how to do so. https://www.npmjs.com/package/grunt-xmlstoke#example---deleting-nodes. If it works or not, please post back to continue the conversation. Happy coding.

Thank very much for quick response. I will try xmlstoke and will let you know the result. 🙂

Hi Diego,

Thanks a lot for your help. xmlstoke solution seems working. I have one another question. Can I comment/uncomment particular xml tag using either xmlpoke or xmlstoke ? Thanks in advance for your time. 🙂

That's great @utsav kansara! Grunt XMLstoke doesn't seem to provide those capabilities. But I think you can leverage grunt-replace to handle that scenario. In your case, the field might be always commented out and based on the environment argument, you can grunt-replace the field with an uncommented value.

BTW, The developer community would be grateful to learn how you leveraged Grunt XMLstock in your build. If you get a chance, take a moment to post your solutions in the community 🙂

Cheers!

Hi Diego,

Thanks very much for all the help. I got things done using grunt-xmlstoke. Instead of keeping tag commented, by default there will be no tag. I will insert that tag based on the environment and the organization while deploying proxy. I will also play with grunt-replace so that in future if need arises I can use that too. 🙂

Cheers !

Not applicable

Excellent! Thanks!