SVG – Not Able to Open .svg Files: XML Parse Error

svg

Upgraded to 20.04 today and, somehow, Document Viewer is not able to open .svg files. It keeps giving this error. Previously, when I was using 18.04, everything was working fine. No such errors I encountered.

XML parse error: error code=201 (3) in (null):606:15: Namespace prefix xlink for href on image is not defined

EDIT

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="200" height="200">
  <image id="image0" width="200" height="200" x="0" y="0"
    xlink:href="data:image/png;base64

Best Answer

Your document viewer complains about the svg file having an xlink notation somewhere without being declared. As such, your svg file is not a valid xml and the document viewer complains correctly. Maybe in the newer version it is more strict about it.

To fix your file open it with an editor and make sure the xlink declaration is included in the <svg> tag in the very beginning of your file, it should look something like this:

<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink">

Update: For your file, change this line:

<svg width="200" height="200">

to this:

<svg width="200" height="200"
     xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink">
Related Question