How to return Different Data Formats (JSON, XML) from Spring REST API

Here I am going to show you an example on how to return different data formats from REST API using Spring Boot framework. You may have a requirement that you need to return multiple formats, such as XML, JSON, etc., from the REST response, then this example may help you. This example will return XML and JSON format depending on your HTTP settings. By default the REST will send you the JSON response. You need to set key Accept‘s value in HTTP Headers to text/xml or application/xml to get the…

Continue

How to convert XML to CSV using Python

In this example we are going to see how we can convert XML data into CSV data. XML is an Extensible Markup Language and CSV is Comma Separated Values. In this example I am going to read both XML file and XML string and show you how to display the converted csv string data in console as well as in the output csv file. You can check also check how to convert csv to xml using Python. Both XML and CSV formats being language agnostic are widely used in different…

Continue

SAX – Simple API for XML

Introduction SAX – Simple API for XML, allows you to process a document as it is being read, which avoids the need to wait for all of it to be stored before taking action. So it takes less memory to process an XML document, whereas DOM (Document Object Model) parser first stores the whole document into memory before taking action. Unlike a DOM parser, a SAX parser creates no parse tree. The SAX API allows a developer to capture the following events generated by SAX parser:

Continue

DOM – Document Object Model

What is DOM ? A DOM – Document Object Model is a collection of nodes, or pieces of information, organized in a hierarchy. This hierarchy allows a developer to navigate around the tree looking for specific information. Analyzing the structure normally requires the entire document to be loaded and the hierarchy to be built before any work is done. Because it is based on a hierarchy of information, the DOM is said to be tree-based, or object-based. For exceptionally large documents, parsing and loading the entire document can be slow…

Continue

Modifying XML using Python

Introduction Modifying XML using Python programming language means updating or modifying an existing XML file or XML string using Python. Extensible Markup Language (XML) are the most widely used formats for data, because this format is very well supported by modern applications, and is very well suited for further data manipulation and customization. Therefore it is sometimes required to generate XML data using Python or other programming languages. We have seen how to parse or read an existing XML document and build or create a new XML document using Python.…

Continue

Building XML using Python

Introduction Building XML using Python programming language means creating an XML file or XML string using Python. We have seen how to parse or read an existing XML file or string using Python in my previous tutorial. Here we will see how to create an XML file or string using Python from scratch. We will not only create the XML file but also do pretty print the XML data. We have defined one method for pretty printing the XML elements. Extensible Markup Language (XML) are the most widely used formats…

Continue

Parsing XML using Python

Introduction Parsing XML using Python is a matter of few lines of code has to be written.  The XML could be in a file or XML could be a string. So basically parsing XML using Python means reading the XML node data and further doing something with those data to use in our application. Extensible Markup Language (XML) are the most widely used formats for data, because this format is very well supported by modern applications, and is very well suited for further data manipulation and customization.

Continue

How to Convert CSV to XML using PHP

Introduction The example, convert csv to xml using PHP , shows conversion of csv data to xml data. As the title suggests to convert csv to xml using PHP, so we will convert either csv file to xml file or csv string to xml string. When we convert csv string to xml string you will see the output on the browser and when we convert csv file to xml file then you will see the xml document saved into a file on the physical drive location. So here in this example…

Continue

How to Convert XML to CSV using PHP

Introduction The example, convert xml to csv using PHP , shows conversion of xml data to csv data. As the title suggests to convert xml to csv using PHP, so we will convert either xml file to csv file or xml string to csv string. When we convert xml string to csv string you will see the output on the browser and when we convert xml file to csv file then you will see the csv document saved into a file on the physical drive location. So here in this example…

Continue