Struggling with xml put, no value #220
-
Given an NLog sample.xml like this:
I'd like to add more
Ultimately I want to
Result:
Ideally I want no value and a new |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hey, thanks for the question. I've had a play around and the issue here is with the XML parser providing somewhat of a ghost root node. A simple workaround that works is the following: dasel put document -f sample.xml -d json -o out.xml 'nlog.rules.logger.[]' '{"-name":"JsonRpc.*","-minlevel":"Error","-writeTo":"file-async"}' Example: The original file: $ cat sample.xml
<nlog>
<rules>
<logger name="JsonWebAPI.Microsoft.Extensions.Diagnostics.HealthChecks.DefaultHealthCheckService" maxLevel="Error" final="true" />
<logger name="JsonWebAPI*" minlevel="Error" writeTo="file-async" />
<logger name="JsonWebAPI*" minlevel="Error" writeTo="auto-colored-console-async" final="true" />
<logger name="JsonWebAPI*" final="true" />
<logger name="*" minlevel="Off" writeTo="seq" />
<logger name="*" minlevel="Info" writeTo="file-async" />
<logger name="*" minlevel="Info" writeTo="auto-colored-console-async" />
</rules>
</nlog> Using dasel: $ dasel put document -f sample.xml -d json -o out.xml 'nlog.rules.logger.[]' '{"-name":"JsonRpc.*","-minlevel":"Error","-writeTo":"file-async"}' The output: $ cat out.xml
<nlog>
<rules>
<logger final="true" maxLevel="Error" name="JsonWebAPI.Microsoft.Extensions.Diagnostics.HealthChecks.DefaultHealthCheckService"/>
<logger minlevel="Error" name="JsonWebAPI*" writeTo="file-async"/>
<logger final="true" minlevel="Error" name="JsonWebAPI*" writeTo="auto-colored-console-async"/>
<logger final="true" name="JsonWebAPI*"/>
<logger minlevel="Off" name="*" writeTo="seq"/>
<logger minlevel="Info" name="*" writeTo="file-async"/>
<logger minlevel="Info" name="*" writeTo="auto-colored-console-async"/>
<logger minlevel="Error" name="JsonRpc.*" writeTo="file-async"/>
</rules>
</nlog> Honestly I'm not sure why the spacing on the first item is off though, I'm happy to keep this issue open while I do some digging but this should unblock you short term. |
Beta Was this translation helpful? Give feedback.
-
Thanks a ton for taking the time to dig into that! I wouldn't have figured that out in an age. |
Beta Was this translation helpful? Give feedback.
Hey, thanks for the question.
I've had a play around and the issue here is with the XML parser providing somewhat of a ghost root node.
A simple workaround that works is the following:
Example:
The original file: