How to Print XML? Simple 2 Step Process

Jun 4, 2020

2 mins read

Published in
XML
How to print XML?

How to print XML? what kind of blog is this? is there a use of printer nowadays? hmm…

So the right question would be where do you print the XML? on browser console? on PDF ? on Papar (really!!)? or just want to format the XML data.

Let’s start with printing xml on browser console.

Here is the code which uses vkbeautify javascript library which prints XML into the console.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
<!DOCTYPE html>
<html>
  <body>
    <script src="https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/vkbeautify/vkbeautify.0.99.00.beta.js"></script>
    <script>
      var parser, xmlDoc;
      var text =
        "<employees><employee><id>1</id><firstName>Leonardo</firstName><lastName>DiCaprio</lastName></employee></employees>";

      console.log(vkbeautify.xml(text));
    </script>
  </body>
</html>

Copy the HTML code and create .html file, open in browser and open console to see the beautiful XML will be in Browser console log.

Here is a way to create XML PDF. I don’t want to go into complex coding do to this. I have developed a tool which will help to do the same.

Follow this steps.

Go to XML Pretty Print tool.

how to print xml, open, https://jsonformatter.org/xml-pretty-print

ho Copy and paste you XML in Input XML Text area or click on Sample link

Click on XML Print button, which will open a print view of XML. Now you have the option to Print or Save as PDF.

how to print XML which helps to print in PDF or on Paper.

Print view with XML data.

This article helps to Print beautiful XML on Brower Console, PDF and on Paper.

Advance topic XML from URL and File.

Now we are going for more advance into this topic what if you have URL or File which you want to beautify and print?

Here are the steps for the XML from URL.

XML from URL

Go to XML Pretty Print tool. Click on “Load Data” button, which will open a dialogue box to enter a URL string into Text.

Paste your XML URL into the textbox and hit Load URL. It will fetch the data from the URL and update the Input XML text area. Click on XML Print to Write XML to PDF or Paper.

Load XML data from URL

Upload data Popup

XML from File

Go to XML Pretty Print tool. Click on “Load Data” button, which will open a dialogue box.

Click Upload File button which will open a file selector. Select XML file and Hit Open.

XML file will be uploaded and loaded in the Input XML area.

Click XML Print to Print XML to PDF or Paper.

Follow https://codeblogmoney.com/validate-json-string-using-javascript/

Sharing is caring!