Created
August 20, 2011 03:12
-
-
Save joseph-montanez/1158594 to your computer and use it in GitHub Desktop.
XPath Compiling Issues?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | |
^^^^^^^^^^^^^ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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