Kristopher
Kristopher

Reputation: 868

How can I pull Google Voice data?

Google Voice has XML URLs so I was wondering how somebody would pull the JSON part from the returned XML and parse it out to a page. Google Voice's search capability is busted right now and I want to get access to my history. I'm thinking that a synchronous call to all of the pages up to the last known page number in my history should do it...

Upvotes: 2

Views: 753

Answers (2)

therealklanni
therealklanni

Reputation: 652

This may be your best bet...

Read about dataType conversion here: http://api.jquery.com/extending-ajax/

Particularly the section that says:

You can define converters "inline," inside the options of an ajax call. For example, the following code requests an XML document, then extracts relevant text from it, and parses it as "mydatatype":

$.ajax( url, {
  dataType: "xml text mydatatype",
  converters: {
    "xml text": function( xmlValue ) {
      // Extract relevant text from the xml document
      return textValue;
    }
  }
});

I don't know if this exact code snippet will return the JSON content properly, but at the very least it should strip it out of the XML response (you may need to add additional code to parse the returned "textValue" as JSON. Perhaps using the jQuery parseJSON method.

Maybe try:

$.ajax( url, {
  dataType: "xml text mydatatype",
  converters: {
    "xml text": $.parseJSON;
    }
  }
});

Hope this helps.

Upvotes: 2

therealklanni
therealklanni

Reputation: 652

XML and JSON are not the same data types. You will likely have to process the data as XML, if that's the only type your data is returned as. If the URL has .xml, you might try changing it to .json to see if it returns a JSON data type.

If you give us more information (examples, URLs, etc), someone might be able to help you better.

Upvotes: 1

Related Questions