diff --git a/README.md b/README.md index 6c2467b..af394c8 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,38 @@ From [Wikipedia][oga-wikipedia]: > power saws. One person stood on a raised platform, with the board below him, > and the other person stood underneath them. +## Examples + +Parsing a simple string of XML: + + Oga.parse_xml('Alice') + +Parsing a simple string of HTML: + + Oga.parse_html('') + +Parsing an IO handle pointing to XML (this also works when using +`Oga.parse_html`): + + handle = File.open('path/to/file.xml') + + Oga.parse_xml(handle) + +Querying a document using XPath: + + document = Oga.parse_xml('Alice') + + document.xpath('string(people/person)') # => "Alice" + +Modifying a document and serializing it back to XML: + + document = Oga.parse_xml('Alice') + name = document.at_xpath('people/person[1]/text()') + + name.text = 'Bob' + + document.to_xml # => "Bob" + ## Features * Support for parsing XML and HTML(5)