https://github.com/a6b8/xml-tree-viewer-for-ruby
A .xml string will do up to a easy readable tree strcuture for terminal output.
https://github.com/a6b8/xml-tree-viewer-for-ruby
atom nokogiri rss ruby xml
Last synced: about 1 year ago
JSON representation
A .xml string will do up to a easy readable tree strcuture for terminal output.
- Host: GitHub
- URL: https://github.com/a6b8/xml-tree-viewer-for-ruby
- Owner: a6b8
- License: mit
- Created: 2021-06-27T03:13:27.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2022-01-21T02:30:34.000Z (over 4 years ago)
- Last Synced: 2025-02-13T01:48:48.837Z (over 1 year ago)
- Topics: atom, nokogiri, rss, ruby, xml
- Language: Ruby
- Homepage:
- Size: 760 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
A .xml string will do up to a easy readable tree strcuture for terminal output.
### Detail
**Code**
```ruby
require 'xml_tree_viewer'
xml = XmlTreeViewer.helper()
XmlTreeViewer.generate( xml, :detail )
```
**Output**
```txt
TREE OVERVIEW
employees
doc.css('employees')
┗━ employee
doc.css('employees > employee:nth-of-type(1)')
┗━ fullname
doc.css('employees > employee:nth-of-type(1) > fullname')
┗━ employee
doc.css('employees > employee:nth-of-type(2)')
┗━ fullname
doc.css('employees > employee:nth-of-type(2) > fullname')
```
### Short
**Code**
```ruby
require 'xml_tree_viewer'
xml = XmlTreeViewer.helper()
XmlTreeViewer.generate( xml, :short )
```
**Output**
```txt
TREE OVERVIEW
employees
┗━ employee
┗━ fullname
┗━ employee
┗━ fullname
```
1. [Examples](#examples)
2. [Quickstart](#quickstart)
3. [Setup](#setup)
4. [Methods](#methods)
5. [Contributing](#contributing)
6. [Limitations](#limitations)
7. [Credits](#credits)
8. [License](#license)
9. [Code of Conduct](#code-of-conduct)
10. [Support my Work](#support-my-work)
```ruby
require '../lib/xml_tree_viewer'
xml = XmlTreeViewer.helper()
XmlTreeViewer.generate( xml, :detail )
```
Add this line to your application's Gemfile:
```ruby
gem 'xml_tree_viewer'
```
And then execute:
$ bundle install
Or install it yourself as:
$ gem install xml_tree_viewer
On Rubygems:
- Gem: https://rubygems.org/gems/xml_tree_viewer
- Profile: https://rubygems.org/profiles/a6b8
### .helper()
Output a sample xml string
```ruby
xml = XmlTreeViewer.helper()
```
### .generate()
Generate xml tree from string input
```ruby
XmlTreeViewer.generate(
xml,
mode
)
```
**Input**
| **Type** | **Required** | **Description** | **Example** | **Description** |
|------:|:------|:------|:------|:------|
| **xml** | ```String``` | Yes | "Test" | Define path structure |
| **mode** | ```Symbol``` | Yes | ```:detail``` | Set console mode. Use ```:detail```, ```:short``` or ```:silent``` |
**Return**
Boolean
Bug reports and pull requests are welcome on GitHub at https://github.com/a6b8/xml-tree-viewer-for-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/a6b8/xml-tree-viewer-for-ruby/blob/master/CODE_OF_CONDUCT.md).
- Tested for Rss and Atom Feeds.
This gem depend on following gems:
- [nokogiri](https://rubygems.org/gems/nokogiri)
- [active_support](https://rubygems.org/gems/activesupport)
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
Everyone interacting in the xml-tree-viewer-for-ruby project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/a6b8/xml-tree-viewer-for-ruby/blob/master/CODE_OF_CONDUCT.md).
Please ⭐️ star this Project, every ⭐️ star makes us very happy!