Skip to content
forked from zenith391/vwxml

Pure V library for parsing XML.

License

Notifications You must be signed in to change notification settings

walkingdevel/vxml

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vxml

Project status Test V modules reference MIT

Pure V library for parsing XML. The data is accessed with a tree API accessible directly within the Node struct.

Install

v install walkingdevel.vxml

Example

import walkingdevel.vxml { parse_file }

fn main() {
  news := parse_file('./news.xml') or { panic(err) }

  posts := news.get_elements_by_tag_name('post')

  println(posts.first().get_text())
}

API

fn parse(xml string) Node
fn parse_file(path string) !Node

struct Node {
pub mut:
        attributes map[string]string
        name       string
        text       string
        cdata      string
        children   []&Node
        parent     &Node
}

fn (node Node) is_root() bool
fn (node Node) get_elements_by_tag_name(name string) []&Node
fn (node Node) get_element_by_tag_name(name string) !&Node
fn (node Node) get_elements_by_predicate(predicate fn (&Node) bool) []&Node
fn (node Node) get_attribute(name string) !string
fn (node Node) get_text() string
fn (node Node) get_cdata() string

Roadmap

  • Error handling
  • Schemas (DTD)

License

This project is under the MIT License. See the LICENSE file for the full license text.

About

Pure V library for parsing XML.

Topics

Resources

License

Stars

Watchers

Forks

Languages

  • V 98.1%
  • AMPL 1.9%