Skip to content

Add support for modifying nodes like in jq #51

@ghostbuster91

Description

@ghostbuster91

Problem Statement

Sometimes I need to modify an xml file from the script. I could use sed but IMO it is error prone as it does not understand xml structure.

jq supports modifying values as follows:

$ curl https://dummyjson.com/products/1  | jq '.id=2'  
{
  "id": 2, # this was originally 1
  "title": "iPhone 9",
  "description": "An apple mobile which is nothing like apple",
  "price": 549,
  "discountPercentage": 12.96,
  "rating": 4.69,
  "stock": 94,
  "brand": "Apple",
  "category": "smartphones",
  "thumbnail": "https://i.dummyjson.com/data/products/1/thumbnail.jpg",
  "images": [
    "https://i.dummyjson.com/data/products/1/1.jpg",
    "https://i.dummyjson.com/data/products/1/2.jpg",
    "https://i.dummyjson.com/data/products/1/3.jpg",
    "https://i.dummyjson.com/data/products/1/4.jpg",
    "https://i.dummyjson.com/data/products/1/thumbnail.jpg"
  ]
}

It would be great to have the same provided by xq.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions