From 9b68ba4b2648030a7c7cebd861ae54ba5c208ba0 Mon Sep 17 00:00:00 2001 From: Postmodern Date: Fri, 29 Sep 2023 13:44:32 -0700 Subject: [PATCH] Added an Examples section to the README. --- README.md | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/README.md b/README.md index 45c2d60..0fbd35d 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,87 @@ provides many helper methods for parsing HTML/XML, fetching web pages, etc. * Provides helper methods for parsing HTML/XML. +## Examples + +```ruby +require 'ronin/support/web' +include Ronin::Support::Web + +html_parse "..." +# => # +``` + +### HTML + +Parse an HTML file: + +```ruby +html_parse(open('some_file.html')) +# => +# +# +# +# +# +``` + +Build a HTML document: + +```ruby +doc = html_build do + html { + head { + script(:type => 'text/javascript', :src => 'redirect.js') + } + } +end + +puts doc.to_html +# +# +``` + +### XML + +Parse an XML response body: + +```ruby +xml_parse(response.body) +# => +# +# +# admin +# 0mni +# +# +``` + +Build a XML document: + +```ruby +doc = xml_build do + playlist { + mp3 { + file { text('02 THE WAIT.mp3') } + artist { text('Evil Nine') } + track { text('The Wait feat David Autokratz') } + duration { text('1000000000') } + } + } +end + +puts doc.to_xml +# +# +# +# 02 THE WAIT.mp3 +# Evil Nine +# The Wait feat David Autokratz +# 1000000000 +# +# +``` + ## Requirements * [Ruby] >= 3.0.0