This commit is contained in:
Mike Farah
2023-11-23 11:59:14 +11:00
parent b06ab987b1
commit cac23ac003
11 changed files with 170 additions and 14 deletions
+1 -3
View File
@@ -129,15 +129,13 @@ zoo:
```
## Parse xml: force all as an array
Because of the way yq works, when updating everything you need to update the children before the parents. By default `..` will match parents first, so we reverse that before updating.
Given a sample.xml file of:
```xml
<zoo><thing><frog>boing</frog></thing></zoo>
```
then
```bash
yq -oy '([..] | reverse | .[]) |= [] + .' sample.xml
yq -oy '.. |= [] + .' sample.xml
```
will output
```yaml