Skip to content

Instantly share code, notes, and snippets.

@joseph-montanez
Created August 20, 2011 03:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joseph-montanez/1158594 to your computer and use it in GitHub Desktop.
Save joseph-montanez/1158594 to your computer and use it in GitHub Desktop.
XPath Compiling Issues?
valac --version
Vala 0.13.2
valac --vapidir=vapi --pkg libsoup-2.4 --pkg libxml-2.0 --thread -g --save-temps main.vala
main.vala:24.24-24.33: error: The name `type' does not exist in the context of `Xml.XPath.Object*'
if (nodes != null && nodes.type == Xml.XPath.ObjectType.NODESET)
^^^^^^^^^^
main.vala:27.44-27.56: error: The name `nodeset' does not exist in the context of `Xml.XPath.Object*'
nodes.nodeset.length());
^^^^^^^^^^^^^
Compilation failed: 4 error(s), 0 warning(s)
main.vala:28.24-28.36: error: The name `nodeset' does not exist in the context of `Xml.XPath.Object*'
for (int i = 0; i < nodes.nodeset.length(); i++) {
^^^^^^^^^^^^^
main.vala:30.35-30.47: error: The name `nodeset' does not exist in the context of `Xml.XPath.Object*'
nodes.nodeset.item(i).get_path());
^^^^^^^^^^^^^
void main () {
var id = "105113917365398481197";
var url = @"https://www.googleapis.com/buzz/v1/activities/$id/@public";
// create an HTTP session to google
var session = new Soup.SessionAsync ();
var message = new Soup.Message ("GET", url);
// send the HTTP request
session.queue_message (message, (sess, mess) => {
// Load XML
var doc = Xml.Parser.parse_doc ((string) mess.response_body.data);
// Search for Posts
Xml.XPath.order_doc_elements (doc);
var xpath = new Xml.XPath.Context(doc);
unowned Xml.XPath.Object results = xpath.eval("//content");
// Go through results
if (results != null && results.type == Xml.XPath.ObjectType.NODESET) {
unowned Xml.XPath.NodeSet nodes = results.nodesetval;
printerr ("got %d nodes\n", nodes.length());
for (int i = 0; i < nodes.length(); i++) {
unowned Xml.Node node = nodes.item(i);
printerr (" -> %s\n", node.get_path());
}
}
});
session.send_message (message);
}
all:
valac --version
valac --vapidir=vapi --pkg libsoup-2.4 --pkg libxml-2.0 --thread -g --save-temps main.vala
./main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment