Skip to content

ychen306/Microdata-Parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Microdata Parser in Go. Usage:

import (
  "mcrdata"
  ...
)

resp, _ := http.Get(url)
page, _ := ioutil.ReadAll(resp.Body)
node := mcrdata.Parse(page)
items := node.FindAll()

APIs: To prepare a document before searching items, use func Parse.

func Parse(page []byte) *Node {...}

To search items within a Node, use func Findall for all items or func Find for item of a specific type.

func (node *Node) FindAll() []*Item {...}
func (node *Node) Find(itemtype string) []*Item {...}

To get property of an item, use func Get, which returns a slice of Property.

func (item *Item) Get(property string) []Property {...}

Here is the list of functions implemented by Property.

func Value() string {...} // returns its value if the property is a plain data
func Properties() []string {...} // returns a slice of properties if the property is an Item
func Type() string {...} // returns type of the property
func Get(property string) []Property {...} // returns values of given property if the property is an Item

Note that Node is a type within package mcrdata, which internally uses Node from gokogiri.

To search items within an existing gokogiri node, wrap it using func ParseXmlNode

func ParseXmlNode(node *xml.Node) *Node {...}

About

Parser for Microdata (https://www.w3.org/TR/microdata/) written in Golang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages