Altova XMLSpy 2024 Enterprise Edition

Images can be displayed directly in Grid View in its graphical representation (see screenshots below: XML Grid View at left, JSON Grid View at right). In order for this to happen, the image must be stored in the file in its Base64-encoding (and not as a reference to an image file)

Click to expand/collapse     Click to expand/collapse

There are two ways to insert the Base64-encoding of an image in a Grid View cell:


Create a node that is of type Formula. In the formula expression cell (see screenshot above), enter the following XPath expression to convert an image to its Base64 encoding: unparsed-text("<Image-URL>", "x-binarytobase64"). The XPath function unparsed-text converts the image to Base64 encoding. The image will be stored as Base64-encoded text (which you can see in Text View), but will be rendered in its graphic form below the cell containing the formula expression.

Place the cursor in the cell into which you want to add the image. For example, in the screenshot above, the image is added as content of the second Image element by selecting the Image element. Then select Edit | Insert | Encoded External File. In the dialog that appears: (i) enter the path to the image you want (local or internet), (ii) select Base 64, (iii) select Create Text. The image will be converted to its Base64 encoding, and the encoded text will be entered as text in the selected node. (In XML Grid View, you can alternatively create the Base64 text as a new child element.) You can see the encoded text in Text View. However, in Grid View, you will see, not the encoding, but a rendering of the image in the cell (see screenshot above).


Image URLs can be given in the following forms, including as relative paths:





Most of the image formats that are commonly used are supported. These include PNG, JPEG, BMP, and animated GIFs. SVG is read as an XML document; in Grid View, the image is displayed as the last child of the <svg> element.


Save a Base64-encoded image string as an image file

The Base64 encoding of an image is simple text. In XMLSpy, you can generate this text into an image file having the image format that is encoded in the Base64 text string. To save a Base64-encoded string in its image format, right-click the image or its cell and select the command Save as Image. (Note that, although the image is displayed in Grid View as an image, it is actually stored in the file as a Base64 string.) In the dialog that appears, select the location where you want to save the image and enter a name for the image file. The extension of the image file (.png, .gif, .svg, etc) will be auto-detected from the Base64 encoding and will appear in the Save dialog. Click Save when done.


This action can also be carried out via the Edit | Save as Image menu command.


© 2018-2024 Altova GmbH