Download presentation
Presentation is loading. Please wait.
1
Both XML ad JSON are designed to transport data
XML and JSON XML JSON Growth, Popularity Availability Both XML ad JSON are designed to transport data
2
What is XML? XML stands for eXtensible Markup Language
XML was designed to store and transport data The Difference Between XML and HTML XML designed to carry data - with focus on what data is HTML was designed to display data - with focus on how data looks XML is Extensible Most XML applications will work as expected even if new data is added (or removed). <note> <date> </date> <hour>08:30</hour> <to>Tove</to> <from>Jani</from> <body>Don't forget me this weekend!</body> </note> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>
3
XML Example - Meetup
4
XML Tree Structure
5
What is JSON? JSON stands for JavaScript Object Notation
JSON is lightweight data interchange format JSON is language independent The JSON syntax is derived from JavaScript object notation syntax, but the JSON format is text only. Code for reading and generating JSON data can be written in any programming language.
6
JSON Example - Meetup
7
JSON Syntax Rules Data is in name/value pairs
Data is separated by commas Curly braces hold objects Square brackets hold arrays "firstName":“Larry" {"firstName":“Larry", "lastName":“Bird"} “celtics":[ {"firstName":“Larry", "lastName":“Bird"}, {"firstName":“Bill", "lastName":“Russell"}, {"firstName":“Paul", "lastName":“Pierce"} ]
8
Both XML ad JSON are designed to transport data
9
http://www. programmableweb. com/wp-content/xml-json-all-time1-600x382
11
https://developer.linkedin.com/docs/rest-api
12
Twitter – JSON Only https://dev.twitter.com/faq/rest-api-v1.1
13
Website API? WYSIWYG What data is available? Subset Public Is a Key needed? Private / Key XML XML and/or JSON JSON
14
Meetup API
15
Create URL String Copy and Paste the URL into your Web Browser
#set up url string url1 = ' url2 = 'category_id=34' url3 = '&zip=02201' url4 = '&format=xml' url5 = '&offset=0' url6 = '&key=XXXXXXXXXXXXXXXXXXXXXXXXXX' url_string = paste( url1, url2,url3, url4, url5, url6, sep="" ) url_string class(url_string) Copy and Paste the URL into your Web Browser
16
R Packages and Performing API Call
library(XML) groups.x <- xmlTreeParse(url_string, useInternal=TRUE) library(jsonlite) groups.j <- fromJSON(url_string)
17
How to Extract Data from Tree?
# JSON class(groups.j) name.j.DF <- groups.j$results # XML name.x <- (sapply(getNodeSet(groups.xtop, "//item/name"),xmlValue)) class(name.x) name.x.DF <- as.data.frame(name.x)
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.