Skip to content

Commit ede09fe

Browse files
authored
docs: add XML file usage examples to usage, man page, and README (#152)
Add --xml-root / --xml-row flag examples in all three documentation locations so users can discover XML input support for nested documents like RSS feeds: - src/args.zig (--help): add XML example with --xml-root / --xml-row - docs/sql-pipe.1.scd: add two XML EXAMPLES entries (nested input with --xml-root/--xml-row, custom output element names) - README.md: expand XML section with RSS-style nested-input example Closes #144
1 parent 4e94a6c commit ede09fe

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,19 @@ $ printf 'name,age\nAlice,30\nBob,25' | sql-pipe -O xml 'SELECT * FROM t'
207207
$ cat data.xml | sql-pipe -I xml 'SELECT name FROM t WHERE age > 25'
208208
```
209209

210+
Real-world XML documents (RSS feeds, API responses) nest rows inside a container element. Use `--xml-root` to navigate to the row container and `--xml-row` to filter by element tag:
211+
212+
```sh
213+
# Query an RSS feed: channel/item → rows
214+
$ curl -s https://feeds.feedburner.com/TheHackersNews \
215+
| sql-pipe -I xml --xml-root channel --xml-row item \
216+
'SELECT title FROM t LIMIT 5'
217+
218+
# Query XML with a custom root and row name
219+
$ cat events.xml | sql-pipe -I xml --xml-root events --xml-row event \
220+
'SELECT name, date FROM t WHERE type = "conference"'
221+
```
222+
210223
Chain queries by piping back in — useful for two-pass aggregations. Pass `-H` to the first call so the second one sees column names:
211224

212225
```sh

docs/sql-pipe.1.scd

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,16 @@ EXAMPLES
183183

184184
$ cat data.xml | sql-pipe -I xml 'SELECT name FROM t WHERE age > 25'
185185

186+
Query XML input with nested structure using --xml-root and --xml-row (e.g. RSS feeds):
187+
188+
$ curl -s https://feeds.example.com/news.rss \
189+
| sql-pipe -I xml --xml-root channel --xml-row item 'SELECT title FROM t LIMIT 5'
190+
191+
Output results as XML with custom element names:
192+
193+
$ cat data.csv \
194+
| sql-pipe -O xml --xml-root feed --xml-row entry 'SELECT * FROM t'
195+
186196
Preview schema and first 3 rows of a CSV file:
187197

188198
$ cat sales.csv | sql-pipe --sample 3

src/args.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ pub fn printUsage(writer: *std.Io.Writer) !void {
202202
\\ cat data.csv | sql-pipe --output-format json 'SELECT * FROM t'
203203
\\ cat data.json | sql-pipe --input-format json 'SELECT * FROM t'
204204
\\ cat data.ndjson | sql-pipe -I ndjson -O ndjson 'SELECT name FROM t WHERE age > 18'
205+
\\ cat data.xml | sql-pipe -I xml --xml-root channel --xml-row item "SELECT title FROM t"
205206
\\ cat data.csv | sql-pipe --sample 5
206207
\\
207208
);

0 commit comments

Comments
 (0)