[redland-dev] Raptor atom parsing - need help
Diluka Moratuwage
diluka at wso2.com
Mon May 14 09:46:51 BST 2007
Hi,
I'm trying to use the raptor rdf parser/serializer library, the problem
i'm having is
that i can't figure out how the element of a parsed file is accessed. I
went through
the methods the library supplied, but unfortunately i couldn't get it done.
In my scenario, i have the atom file(atom.xml)
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Example Feed</title>
<link href="http://example.org/"/>
<updated>2003-12-13T18:30:02Z</updated>
<author>
<name>John Doe</name>
</author>
<id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
<entry>
<title>Atom-Powered Robots Run Amok</title>
<link href="http://example.org/2003/12/13/atom03"/>
<id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
<updated>2003-12-13T18:30:02Z</updated>
<summary>Some text.</summary>
</entry>
</feed>
And i have modified the rdfprint.c sample program to read this atom.xml
file
and parse it. The program uses "rss-tag-soup" parser, and it parses the
successfully. But the problem is that i couldn't access the parsed
file's element.
Following is the code in my modified rdfprint.c file,
int main()
{
raptor_parser* rdf_parser=NULL;
unsigned char *uri_string;
raptor_uri *uri, *base_uri;
printf("Diluka...\n");
raptor_init();
//rdf_parser=raptor_new_parser("rdfxml");
rdf_parser=raptor_new_parser("rss-tag-soup");
raptor_set_statement_handler(rdf_parser, NULL, print_triple);
uri_string=raptor_uri_filename_to_uri_string(argv[1]);
uri=raptor_new_uri(uri_string);
base_uri=raptor_uri_copy(uri);
raptor_parse_file(rdf_parser, uri, base_uri);
raptor_free_parser(rdf_parser);
raptor_free_uri(base_uri);
raptor_free_uri(uri);
raptor_free_memory(uri_string);
raptor_finish();
}
Can anyone pls at least give me a hint, or an example program that
illustrates how to go through the parsed atom file.
I don't mind if it uses a rss file, i just want to know how the methods
should be used to access the elements in the file.
Thnaks a lot.
Diluka.
More information about the redland-dev
mailing list