Change readme accordingly
This commit is contained in:
parent
7f30fd5411
commit
4c38753ff7
32
README.md
32
README.md
@ -15,8 +15,8 @@ go get git.streifling.com/jason/atom@latest
|
||||
## Usage
|
||||
|
||||
This library provides convenient functions to safely create and extend elements
|
||||
and attributes of an Atom feed. This is because it can be hard to know all
|
||||
pitfalls of RFC4287. The intended way of using atom is with these functions.
|
||||
and attributes of Atom feeds. It also provides checks for all constructs'
|
||||
adherence to RFC4287.
|
||||
|
||||
```go
|
||||
package main
|
||||
@ -29,30 +29,28 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
feed, err := atom.NewFeed("Example Feed")
|
||||
if err != nil {
|
||||
feed := atom.NewFeed("Example Feed")
|
||||
feed.Title = atom.NewText("text", "Example Feed")
|
||||
feed.ID = atom.NewID(atom.NewURN())
|
||||
if err := feed.Check(); err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
author := atom.NewPerson("John Doe")
|
||||
author.Email = "john.doe@example.com"
|
||||
if err := author.Check(); err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
feed.AddAuthor(author)
|
||||
|
||||
entry, err := atom.NewEntry("First Entry")
|
||||
if err != nil {
|
||||
entry := atom.NewEntry("First Entry")
|
||||
entry.ID = atom.NewID(atom.NewURN())
|
||||
entry.Content = atom.NewContent(atom.InlineText, "text", "This is the content of the first entry.")
|
||||
if err := entry.Check(); err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
content, err := atom.NewContent(atom.InlineText, "text", "This is the content of the first entry.")
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
entry.Content = content
|
||||
feed.AddEntry(entry)
|
||||
|
||||
if err := feed.Check(); err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
feedString, err := feed.ToXML("utf-8")
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
@ -62,7 +60,7 @@ func main() {
|
||||
```
|
||||
|
||||
It is also possible to use this library in a way similar to what other libraries
|
||||
would provide. This is, of course, making it easier to make mistakes.
|
||||
provide.
|
||||
|
||||
```go
|
||||
package main
|
||||
@ -115,7 +113,7 @@ func main() {
|
||||
}
|
||||
```
|
||||
|
||||
The output of both ways of using it is an RFC4287 compliant Atom feed:
|
||||
The output of both ways of using it is an RFC4287 compliant Atom feed.
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user