Check for Valid XML with PHP

Simple function to check if XML is valid. It just loads the XML into DOMDocument and checks for errors.

[source language=“php“]
/**
* Takes XML string and returns a boolean result where valid XML returns true
*/
function is_valid_xml ( $xml ) {
libxml_use_internal_errors( true );

$doc = new DOMDocument(‚1.0‘, ‚utf-8‘);

$doc->loadXML( $xml );

$errors = libxml_get_errors();

return empty( $errors );
}
[/source]

Export data to Google spreadsheet with OAuth

I was working on exporting CSV data to a Google spreadsheet recently. The first thing I had to do was implement a way to allow a user to authenticate themselves with Google from our site. There are a few ways of doing this.

I choose OAuth as I thought it would be simplest. I found it was pretty straightforward but there were gaps in Google’s documentation that made the process a tad frustrating.

Here’s a brief outline…
Weiterlesen „Export data to Google spreadsheet with OAuth“