Quantcast
Viewing all articles
Browse latest Browse all 30

How to extract value from AtomPub XML HTTP response in Javascript (for Google Apps Admin Settings API)

I am calling the Google Apps Admin Settings API from a Google Apps Script script (Javascript) to retrieve the maximum number of users in our Google Apps domain.

A successful GET request returns the response in AtomPub XML format, like so:

<?xml version='1.0' encoding='UTF-8'?><entry xmlns='http://www.w3.org/2005/Atom' xmlns:apps='http://schemas.google.com/apps/2006'><id>https://apps-apis.google.com/a/feeds/domain/2.0/domain.com/general/maximumNumberOfUsers</id><updated>2014-07-16T00:55:27.837Z</updated><link rel='self' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/domain/2.0/domain.com/general/maximumNumberOfUsers'/><link rel='edit' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/domain/2.0/domain.com/general/maximumNumberOfUsers'/><apps:property name='maximumNumberOfUsers' value='100'/></entry>

The value of the maximumNumberOfUsers property (in this case it's 100) is the only part I care about.

How do I extract that value so I can assign it to an integer variable?

My first instinct was to write a crazy complex regex but I KNOW there must be an easier way!

I think there's a way to do this with JQuery, but there's no way to use jQuery in Google Apps Script.


Viewing all articles
Browse latest Browse all 30

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>