File: README.md

package info (click to toggle)
libxmlbird 1.2.15-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 308 kB
  • sloc: python: 649; xml: 122; sh: 51; makefile: 14
file content (85 lines) | stat: -rw-r--r-- 1,768 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
![xmlbird logo][xmlbird]

# XML Bird – XML parser

XML Bird is an XML parser for programs written in Vala or C.

    Author: Johan Mattsson
    License: LGPL v3
    Webpage: https://birdfont.org/xmlbird.php

## Building from Source

Install valac and Glib first.

Configure, build and install with doit:

    ./configure
    doit
    sudo ./install.py

Configure, build and install without doit:

    ./configure
    ./build.py
    sudo ./install.py

The default prefix is /usr/local but you can set the prefix to /usr

    ./configure --prefix=/usr

Exampel usage:

    using B;

    // Print all tags and attributes in an XML document. 
    // Expected output:
    // tag1
    // tag2
    // attribute1
    public static int main (string[] arg) {
        Tag root;
        XmlParser parser;

        parser = new XmlParser ("""<tag1><tag2 attribute1=""/></tag1>""");	

        if (!parser.validate ()) {
            warning ("Invalid XML.");
            return 1;
        }

        root = parser.get_root_tag ();
        print_tags (root);

        return 0;
    }


    void print_tags (Tag tag) {
        print (tag.get_name ());
        print ("\n");
        print_attributes (tag);

        foreach (Tag t in tag) {
            print_tags (t);
        }
    }

    void print_attributes (Tag tag) {
        Attributes attributes = tag.get_attributes ();
        foreach (Attribute attribute in attributes) {
            print (attribute.get_name ());
            print ("\n");
        }
    }

## Hacking

There is a test suite with benchmarks. Run “doit test”.

XML Bird is a part of the [Birdfont][birdfont] project.

[xmlbird]: https://birdfont.org/images/xmlbird-icon.png "XML Bird icon"
[birdfont]: https://birdfont.org/ "Birdfont – Font Editor"