IP_MODULE_1 (2)
IP_MODULE_1 (2)
IP_MODULE_1 (2)
A. GET-
⚫ The GET method is used to retrieve information from the
given server using a given URI. Requests using GET should
only retrieve data and should have no other effect on the
data.
B. POST –
⚫ A POST request is used to send data to the server, for
example, customer information, file upload, etc. using
HTML forms.
3. HTTPS
⚫ HTTPS stands for Hypertext Transfer Protocol
Secure .
⚫ It is the protocol where encrypted HTTP data is
transferred over a secure connection .
⚫ HTTPS ensures data security over the network –
mainly public networks like Wi-Fi .
⚫ For example
⚫ Consider going to a bank website , say hdfc.com
⚫ Hypertext Transfer Protocol Secure (HTTPS ) is
the secure version of HTTP .
3.1 Working with HTTPS
<note>
<to> Raj </to>
<from>Ravi</from>
<heading>IReminder</heading>
<body> Meeting at 8 am </body>
</note>
Output
⚫ The XML above is quite self –descriptive :
It has sender information.
It has receiver information.
It has heading.
It has a message body.
<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"
/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
⚫ The Schema above is interpreted like this:
⚫ <xs:element name="note"> defines the element called
"note"
⚫ <xs:complexType> the "note" element is a complex
type
⚫ <xs:sequence> the complex type is a sequence of
elements
⚫ <xs:element name="to" type="xs:string"> the element
"to" is of type string (text)
⚫ <xs:element name="from" type="xs:string"> the
element "from" is of type string
⚫ <xs:element name="heading" type="xs:string"> the
element "heading" is of type string
⚫ <xs:element name="body" type="xs:string"> the
element "body" is of type string
XML Schemas are More Powerful than
DTD
⚫ XML Schemas are written in XML
⚫ XML Schemas are extensible to additions
⚫ XML Schemas support data types
⚫ XML Schemas support namespaces
XML DOM
•Because the XML data is structured in a tree form, it can be traversed without
knowing the exact structure of the tree and without knowing the type of data
contained within.
First Child - Last Child
⚫ Look at the following XML fragment:
<bookstore>
<book category="cooking">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
</bookstore>
⚫ In the XML above, the <title> element is the first child of the
<book> element, and the <price> element is the last child of the
<book> element.
⚫ Furthermore, the <book> element is the parent node of the <title>,
<author>, <year>, and <price> elements.
XML DOM - Accessing Nodes
newEle = xmlDoc.createElement("edition");
newText=xmlDoc.createTextNode("first");
newEle.appendChild(newText);
xmlDoc.getElementsByTagName("book")[0].appe
ndChild(newEle);
⚫ Example explained:
⚫ Suppose books.xml is loaded into xmlDoc
⚫ Create a new node <edition>
⚫ Create a new text node "first"
⚫ Append the text node to the <edition> node
⚫ Append the <addition> node to the <book> element
XML DOM Remove Nodes
⚫ The removeChild() method removes a specified node.
⚫ The removeAttribute() method removes a specified
attribute.
⚫ The removeChild() method removes a specified node.
⚫ When a node is removed, all its child nodes are also
removed.
⚫ This code will remove the first <book> element from
the loaded xml:
⚫ Example
⚫ y = xmlDoc.getElementsByTagName("book")[0];
xmlDoc.documentElement.removeChild(y);
⚫ Example explained:
⚫ Suppose books.xml is loaded into xmlDoc
⚫ Set the variable y to be the element node to remove
⚫ Remove the element node by using the
removeChild() method from the parent node
Remove Myself – Remove the current
Node
⚫ The removeChild() method is the only way to remove a
specified node.
⚫ When you have navigated to the node you want to remove, it
is possible to remove that node using the parentNode
property and the removeChild() method:
⚫ Example
⚫ x = xmlDoc.getElementsByTagName("book")[0];
x.parentNode.removeChild(x);
⚫ Example explained:
⚫ Suppose books.xml is loaded into xmlDoc
⚫ Set the variable y to be the element node to remove
⚫ Remove the element node by using the parentNode
property and the removeChild() method
⚫ Remove a Text Node
⚫ The removeChild() method can also be used to
remove a text node:
⚫ Example
⚫ x = xmlDoc.getElementsByTagName("title")[0];
y = x.childNodes[0];
x.removeChild(y);
⚫ Example explained:
⚫ Suppose books.xml is loaded into xmlDoc
⚫ Set the variable x to be the first title element node
⚫ Set the variable y to be the text node to remove
⚫ Remove the element node by using the
removeChild() method from the parent node
⚫ It is not very common to use removeChild() just to
remove the text from a node. The nodeValue
property can be used instead. See next paragraph.
XML Parser
text = "<bookstore><book>" +
"<title>Everyday Italian</title>" +
"<author>Giada De Laurentiis</author>" +
"<year>2005</year>" +
"</book></bookstore>";
⚫ xmlDoc=parser.parseFromString(text,"text/xml");
XSLT
⚫ XSL (eXtensible Stylesheet Language) is a styling language for
XML.
⚫ XSLT stands for XSL Transformations.
⚫ CSS = Style Sheets for HTML
⚫ HTML uses predefined tags. The meaning of, and how to
display each tag is well understood.
⚫ CSS is used to add styles to HTML elements.
⚫ XSL = Style Sheets for XML
⚫ XML does not use predefined tags, and therefore the meaning
of each tag is not well understood.
⚫ A <table> element could indicate an HTML table, a piece of
furniture, or something else - and browsers do not know how to
display it!
⚫ So, XSL describes how the XML elements should be displayed.
What is XSLT?
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Link the XSL Style Sheet to the XML
Document
⚫ Add the XSL style sheet reference to your XML document
("cdcatalog.xml"):
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="cdcatalog.xsl"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
.
.
</catalog>
XSLT <xsl:template> Element
JSON
⚫ JSON Example
⚫ This example is a JSON string:
⚫ '{"name":"John", "age":30, "car":null}'
⚫ It defines an object with 3 properties:
⚫ name
⚫ age
⚫ car
⚫ Each property has a value.
⚫ If you parse the JSON string with a JavaScript
program, you can access the data as an object:
⚫ let personName = obj.name;
let personAge = obj.age;
⚫ What is JSON?
⚫ JSON stands for JavaScript Object Notation
⚫ JSON is a lightweight data-interchange format
⚫ JSON is plain text written in JavaScript object
notation
⚫ JSON is used to send data between computers
⚫ JSON is language independent *
Why Use JSON?
URL is a subset of URI that specifies where A URI is a superset of URL that identifies a
a resource is exists and the mechanism for resource either by URL or URN (Uniform
retrieving it. Resource Name) or both.
The main aim of URI is to find a resource
The main aim is to get the location or
and differentiate it from other resources
address of a resource
using either name or location.
Used in HTML, XML and other files XSLT
URL is used to locate only web pages (Extensible Stylesheet Language
Transformations) and more.
The scheme must be a protocol like HTTP, In URI, the scheme may be anything like a
FTP, HTTPS, etc. protocol, specification, name, etc.
Continued …..
A URI is a superset of URL that
URL is a subset of URI that specifies
identifies a resource either by URL or
where a resource is exists and the
URN (Uniform Resource Name) or
mechanism for retrieving it.
both.
Protocol information is given in the There is no protocol information given
URL. in URI.
Example of URI:
Example of URL: https://google.com
urn:isbn:0-486-27557-4
It contains components such as It contains components like scheme,
protocol, domain, path, hash, query authority, path, query, fragment
string, etc. component, etc.
Not all URIs are URLs since a URI can
All URLs can be URIs
be a name instead of a locator.
10 . REST API
⚫ Representational State Transfer (REST) is an architectural
style that defines a set of constraints to be used for creating
web services.
⚫ REST API is a way of accessing web services in a simple
and flexible way without having any processing.
⚫ REST technology is generally preferred to the more robust
Simple Object Access Protocol (SOAP) technology because
REST uses less bandwidth, simple and flexible making it
more suitable for internet usage.
⚫ It’s used to fetch or give some information from a web
service. All communication done via REST API uses only
HTTP request.
Working:
⚫ In HTTP there are five methods that are commonly
used in a REST-based Architecture i.e., POST, GET,
PUT, PATCH, and DELETE.
⚫ These correspond to create, read, update, and delete
(or CRUD) operations respectively.
⚫ There are other methods which are less frequently
used like OPTIONS and HEAD.
1. GET: The HTTP GET method is used to read (or
retrieve) a representation of a resource .
2. POST: The POST verb is most often utilized
to create new resources. In particular, it’s used to
create subordinate resources.
3. PUT: It is used for updating the capabilities.
However, PUT can also be used to create a resource
in the case where the resource ID is chosen by the
client instead of by the server.
4. DELETE: It is used to delete a resource identified
by a URI. On successful deletion, return HTTP
status 200 (OK) along with a response body.
THANK YOU !!!!!!!!!