xron

package module
v0.0.0-...-dc38a20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2024 License: MIT Imports: 4 Imported by: 0

README

xron

Transform XML into xpath and make it greppable.

Like gron, xron prints every xml element as xpath style line by line.

Usage

$ cat books.xml
<?xml version="1.0" encoding="UTF-8"?>
<books>
  <book ID="extension1" available="yes">
    <title>Book Title 1</title>
    <price>1000</price>
    <category name="novel" id="2"/>
  </book>
  <book ID="extension2">
    <title>Book Title 2</title>
    <price>500</price>
  </book>
</books>

$ xron < books.xml
/
/books
/books/book[@ID="extension1"][@available="yes"]
/books/book[@ID="extension1"][@available="yes"]/title
/books/book[@ID="extension1"][@available="yes"]/title/text() = 'Book Title 1'
/books/book[@ID="extension1"][@available="yes"]/price
/books/book[@ID="extension1"][@available="yes"]/price/text() = '1000'
/books/book[@ID="extension1"][@available="yes"]/category[@name="novel"][@id="2"]
/books/book[@ID="extension2"]
/books/book[@ID="extension2"]/title
/books/book[@ID="extension2"]/title/text() = 'Book Title 2'
/books/book[@ID="extension2"]/price
/books/book[@ID="extension2"]/price/text() = '500'

Install

$ go install github.com/akavel/xron/cmd/xron@latest

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertXmlToXpath

func ConvertXmlToXpath(r io.Reader) (rows []string)

func ConvertXmlToXpathFunc

func ConvertXmlToXpathFunc(r io.Reader, emitRow func(string))

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL