On Wed, 2008-10-22 at 12:05 -0200, Matías De la Puente wrote:
> Thanks for the clarifying! But I am still curious why my code didn't
> work.
> 
> class MyClass {
> public static MarkupParser p;
> 
>    void somefunction() {
>        p.start_element = start_element;
>    }
> 
>    void start_element(
> MarkupParseContext context, string element_name,
>          string[] attribute_names, string[] attribute_values) {
> 
>        //do stuff
>    }
> 
> }
> 
> Could you confirm my problem?
> 
> Can you send me a testcase with the results?
> 
> matias
> 

I found it. 

public class Test
{
    void start (MarkupParseContext context, string element_name,
string[]
attribute_names, string[] attribute_values) throws GLib.Error
    {
        print ("start " + element_name + "\n");
    }

    void end (MarkupParseContext context, string element_name) throws
GLib.Error
    {
        print ("end " + element_name + "\n");
    }

    void text (MarkupParseContext context, string text, ulong text_len)
throws GLib.Error
    {
        print ("text " + text + "\n");
    }

    public Test ()
    {
        MarkupParser parser = {start, end, text, null, null };
        MarkupParseContext context = new MarkupParseContext (parser,
MarkupParseFlags.TREAT_CDATA_AS_TEXT, this, null);

        string xml_file;
        FileUtils.get_contents ("test.xml", out xml_file);
        context.parse (xml_file, xml_file.len ());
    }

    public static void main (string[] args)
    {
        var test = new Test ();
    }
}



_______________________________________________
Vala-list mailing list
Vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to