Documentation ¶
Overview ¶
The parser for [the xml that exported by Evernote (.enex file)](https://evernote.com/blog/how-evernotes-xml-export-format-works/).
Example ¶
enexData := []byte(` <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE en-export SYSTEM "http://xml.evernote.com/pub/evernote-export2.dtd"> <en-export export-date="20190101T130203Z" application="Evernote/Windows" version="6.x"> <note> <title>test note</title> <content><![CDATA[<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note>hello world<br /></en-note>]]></content> <created>20190102T140304Z</created> <tag>shidax</tag> <note-attributes> <subject-date>20190103T150405Z</subject-date> <author>Jhon Due</author> <source>web.clip</source> </note-attributes> <resource> <data encoding="base64">aGVsbG8gd29ybGQ=</data> <mime>text/plain</mime> <resource-attributes> <file-name>test attached file</file-name> <attachment>true</attachment> </resource-attributes> </resource> </note> </en-export> `) parsed, err := enex.Parse(enexData) if err != nil { panic(err.Error()) } j, err := json.MarshalIndent(parsed, "", " ") if err != nil { panic(err.Error()) } fmt.Println(string(j))
Output: { "Notes": [ { "Title": "test note", "Content": { "XML": "\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\u003c!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\"\u003e\u003cen-note\u003ehello world\u003cbr /\u003e\u003c/en-note\u003e" }, "CreatedAt": "20190102T140304Z", "UpdatedAt": "00010101T000000Z", "Tags": [ "shidax" ], "Author": "Jhon Due", "ReceivedAt": "20190103T150405Z", "Source": "web.clip", "Resources": [ { "Data": "aGVsbG8gd29ybGQ=", "Type": "text/plain", "Name": "test attached file", "Attachment": "true", "Recognition": {} } ] } ], "ExportedAt": "20190101T130203Z", "ExportedBy": "Evernote/Windows", "Version": "6.x" }
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EncodedData ¶
type EncodedData struct {
// contains filtered or unexported fields
}
func (*EncodedData) Bytes ¶
func (ed *EncodedData) Bytes() []byte
func (EncodedData) MarshalText ¶
func (ed EncodedData) MarshalText() ([]byte, error)
func (*EncodedData) String ¶
func (ed *EncodedData) String() string
func (*EncodedData) UnmarshalText ¶
func (ed *EncodedData) UnmarshalText(text []byte) error
type EvernoteExportedXML ¶
type EvernoteExportedXML struct { Notes []Note `xml:"note"` ExportedAt DateTime `xml:"export-date,attr"` ExportedBy string `xml:"application,attr"` Version string `xml:"version,attr"` }
func Parse ¶
func Parse(data []byte) (EvernoteExportedXML, error)
Parse .enex file from bytes into EvernoteExportedXML.
`data` is an xml data.
NOTE: This function is just wrapper of xml.Unmarshal. Please directly use xml package if you want customize behavior.
func ParseFromReader ¶
func ParseFromReader(r io.Reader) (EvernoteExportedXML, error)
Parse .enex file from io.Reader into EvernoteExportedXML.
`r` is a reader to read .enex file.
NOTE: This function is just wrapper of xml.Decoder.Decode. Please directly use xml package if you want customize behavior.
type Note ¶
type Note struct { Title string `xml:"title"` Content Content `xml:"content"` CreatedAt DateTime `xml:"created"` UpdatedAt DateTime `xml:"updated,omitempty" json:",omitempty"` Tags []string `xml:"tag"` Author string `xml:"note-attributes>author"` ReceivedAt DateTime `xml:"note-attributes>subject-date,omitempty" json:",omitempty"` Source string `xml:"note-attributes>source,omitempty" json:",omitempty"` SourceURL *url.URL `xml:"note-attributes>source-url,omitempty" json:",omitempty"` Resources []Resource `xml:"resource,omitempty" json:",omitempty"` }
type Recognition ¶
type Recognition struct {
XML string `xml:",cdata" json:",omitempty"`
}
type Resource ¶
type Resource struct { Data EncodedData `xml:"data"` Type string `xml:"mime"` Name string `xml:"resource-attributes>file-name"` Attachment string `xml:"resource-attributes>attachment,omitempty" json:",omitempty"` Width int `xml:"width,omitempty" json:",omitempty"` Height int `xml:"height,omitempty" json:",omitempty"` Recognition Recognition `xml:"recognition,omitempty"` }
Click to show internal directories.
Click to hide internal directories.