@@ -39,10 +39,10 @@ See the [installation guide](`crate::installation_guide`) for installation instr
3939``` none
4040A CEL command-line query tool for JSON data
4141
42- Usage: celq [OPTIONS] < expr|--from-file <FILE>>
42+ Usage: celq [OPTIONS] [ expr]
4343
4444Arguments:
45- [expr] CEL expression to evaluate
45+ [expr] CEL expression to evaluate [default: this]
4646
4747Options:
4848 -a, --arg <name:type=value> Define argument variables, types, and values. Format: name:type=value. Supported types: int, uint, float, bool, string
@@ -53,6 +53,7 @@ Options:
5353 --from-json5 Parse input as JSON5 instead of JSON
5454 --from-toml Parse input as TOML instead of JSON
5555 --from-yaml Parse input as YAML instead of JSON
56+ --from-xml Parse input as XML instead of JSON
5657 --from-gron Parse input as gron (greppable output) instead of JSON
5758 -j, --jobs <N> Parallelism level for NDJSON inputs (number of threads, -1 for all available) [default: 1]
5859 -R, --root-var <ROOT_VAR> Variable name for the root JSON input [default: this]
@@ -144,8 +145,8 @@ This file contains the simplified response from the Yahoo Finance Unofficial JSO
144145 * [ this keyword] ( #this-keyword )
145146 * [ Writing Files] ( #writing-files )
146147 * [ Output JSON] ( #output-json )
147- * [ Slicing lists] ( #slicing-lists )
148148 * [ Reading CEL from a file] ( #reading-cel-from-a-file )
149+ * [ Slicing lists] ( #slicing-lists )
149150 * [ Dealing with NDJSON] ( #dealing-with-ndjson )
150151 * [ Slurping] ( #slurping )
151152 * [ Logical Calculator] ( #logical-calculator )
@@ -156,6 +157,7 @@ This file contains the simplified response from the Yahoo Finance Unofficial JSO
156157 * [ TOML Support] ( #toml-support )
157158 * [ YAML Support] ( #yaml-support )
158159 * [ YAML with multiple documents] ( #yaml-with-multiple-documents )
160+ * [ XML Support] ( #xml-support )
159161 * [ Pretty Printing] ( #pretty-printing )
160162 * [ Raw Output] ( #raw-output )
161163 * [ Grep friendly output] ( #grep-friendly-output )
@@ -444,6 +446,59 @@ The document gets parsed as a list of documents. To access the `tags` field of t
444446celq --from-yaml 'this[1].tags' < multi.yaml
445447` ` `
446448
449+ # ## XML Support
450+
451+ `celq` supports XML via the `--froml-xml` flag. Take `example.xml` :
452+
453+ <details>
454+ <summary>example.xml</summary>
455+
456+ ` ` ` xml
457+ <?xml version="1.0"?>
458+ <items>
459+ <item id="1">
460+ <name>apple</name>
461+ <price>1.25</price>
462+ </item>
463+ <item id="2">
464+ <name>banana</name>
465+ <price>0.75</price>
466+ </item>
467+ </items>
468+ ` ` `
469+ </details>
470+
471+ Running `celq --from-xml -S < example.xml` converts it to the following :
472+
473+ <details>
474+ <summary>example_xml.json</summary>
475+
476+ ` ` ` json
477+ {
478+ "items": {
479+ "item": [
480+ {
481+ "$": {
482+ "id": "1"
483+ },
484+ "name": "apple",
485+ "price": "1.25"
486+ },
487+ {
488+ "$": {
489+ "id": "2"
490+ },
491+ "name": "banana",
492+ "price": "0.75"
493+ }
494+ ]
495+ }
496+ }
497+ ` ` `
498+ </details>
499+
500+ ` celq` ' s XML parser does not try to convert types and puts attributes in the `$` field.
501+
447502### Pretty Printing
448503
449504`celq` by default uses a compact output. This is a contrast to `jq` where the compact output is an opt-in with the `-c` flag.
0 commit comments