-
Good morning, the XML file below contains serial numbers of machines, each of which has a set of variables that I need to extract.
The challenge that I am facing is that these variables may or may not be "dirty" (= not yet committed to the management server). I know that I could pipe the result of dasel into sed to strip the XML attributes:
Or I could run dasel twice:
However, I would like to know if there is an elegant, pure dasel solution that does not double my runtime. Thanks a lot in advance |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Do you have an example expected output for the given XML above? |
Beta Was this translation helpful? Give feedback.
-
Brilliant, that's it - "orDefault" solves my problem. Thank you so much! |
Beta Was this translation helpful? Give feedback.
OK here's what I came up with:
Two parts worth mentioning...
You can extend the query to include multiple serials like this if desired to save you a loop.
filter(or(equal(-name,123),equal(-name,456)))
The change that gives you the expected output here is:
orDefault(ip.#text,ip)
If it can't find the
ip.#text
element, it will fallback and just returnip
.