REST and XML
Estimated study time: 13 minutes.
REST (Representational State Transfer) is an architectural style for web APIs built around standard HTTP methods. Unlike SOAP, REST doesn't require XML — but it can still use it as a data format.
A REST Request Using XML
GET /api/students/1024 HTTP/1.1
Accept: application/xml
A Typical XML Response
<student>
<id>1024</id>
<name>Ananya Sharma</name>
<course>Data Analytics</course>
</student>
REST + XML vs SOAP
- REST uses standard HTTP verbs (GET, POST, PUT, DELETE) directly; SOAP wraps everything in its own envelope.
- REST is flexible about data format (XML, JSON, even plain text); SOAP is XML-only.
- REST has no formal contract by default; SOAP relies on WSDL to describe the service.
REST + XML vs REST + JSON
Most modern REST APIs default to JSON because it's lighter and maps naturally to JavaScript objects. XML is still offered by many APIs as an alternative response format, especially for clients built on older or enterprise tech stacks.
💡 Tip: A well-designed REST API often supports both XML and JSON, letting the client choose via the
Accept header — it's worth knowing how to work with either.