Simple API Enhancements

74 views
Skip to first unread message

Rob

unread,
Mar 25, 2010, 8:14:40 PM3/25/10
to TinyXML++
Hi folks,

I've created a couple simple enhancements to the ticpp API that make
using the library a lot easier for querying simple REST services.

This makes accessing data from, for example, the Yahoo Geocoding API,
much simpler. See the example below.

Any interest in such a contribution?

I see that Matt Trentini has a branch where he is working on something
similar, but there hasn't been much activity of late. What you see
below was done with the addition of a few operator[], operator() and
string conversion methods. Matt's work appears to be a little more
ambitious, attempting to simplify the syntax for both the querying and
construction of XML.

// Sample output can be found here:
// http://developer.yahoo.com/maps/rest/V1/geocode.html

int main()
{
ticpp::Document doc;
try
{
std::ostringstream os;
curlpp::Cleanup myCleanup;
os << curlpp::options::Url(URL);

doc.Parse(os.str());
std::string lat = doc["ResultSet"]["Result"]["Latitude"];
std::string lng = doc["ResultSet"]["Result"]["Longitude"];

std::cout << " Latitude: " << lat << std::endl;
std::cout << "Longitude: " << lng << std::endl;
std::cout << "Precision: " << doc["ResultSet"]["Result"]
("precision")
<< std::endl;
}
catch (std::exception& ex)
{
std::cerr << ex.what() << std::endl;
return 1;
}

return 0;
}


Regards,

Rob

Ryan Mulder

unread,
May 26, 2010, 10:31:51 PM5/26/10
to ti...@googlegroups.com, colora...@gmail.com
Rob,
 Sorry for the long delay. I've given you commit access, if you're still interested.
 Please, commit your code to a branch so we can try it.
-Ryan Mulder


--
You received this message because you are subscribed to the Google Groups "TinyXML++" group.
To post to this group, send email to ti...@googlegroups.com.
To unsubscribe from this group, send email to ticpp+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ticpp?hl=en.


Reply all
Reply to author
Forward
0 new messages