'This SVG is invalid. Validate it before opening

I just modified a svg file that came with my Wordpress Template but i come up to this: Error Line 787, Column 77: there is no attribute "sketch:type"

<g id="city-copy" transform="translate(1305.000000, 47.000000)" sketch:type="MSShapeGroup">


Solution 1:[1]

Open the svg in a text editor and remove the sketch:type="MSShapeGroup" attribute from the <g> element. An even better maneuver would be to optimize your svg with a tool like svgo.

Solution 2:[2]

This can be caused by a variety of things but I've been able to solve this by:

  1. open the SVG in Inkscape
  2. Go To File > Clean Up Document
  3. Save the SVG (choose a unique file name so you do not lose your previous work).

Solution 3:[3]

Check the encoding value.
I changed the encoding="windows-1252" to encoding="utf-8" and worked for me.

Solution 4:[4]

guys! I saw this tip on another forum, and it worked. I managed to fix the corrupted file. What you have to do is:

  • Open the file in a text-editor (I used Dreawweaver)
  • Check the first line for entries like: xmlns:x="&ns_extend;" xmlns:i="&ns_ai;" xmlns:graph="&ns_graphs;", and delete the '&' characters so it reads: xmlns:x="ns_extend;" xmlns:i="ns_ai;" xmlns:graph="ns_graphs;"
  • Save the file, and Illustrator will open it.

Good luck!

Solution 5:[5]

Thanks much for the how-to principle. In my situation, using that idea (of opening the corrupted SVG file with a text editor since Adobe Illustrator wouldn't open the file), I used a text editor (Smultron) to open both the corrupted SVG file and an openable SVG file. I compared the upper area of both files; saw that certain lines of code were missing from the corrupted SVG file; copied those few extra lines of code from the openable (working) SVG; and saved. AI could then open the formerly corrupted SVG file. I copied the layers I needed into a new AI file and abandoned the formerly corrupted SVG.

Solution 6:[6]

AI version CS7 is saving invalid SVG and SVGZ files. In my case, two namespaces were missing from the SVG file.

Use the Export to SVG instead. It save the SVG without the need for namespaces.

Solution 7:[7]

I had similar problems with svg files that I had saved in Adobe Illustrator. The easy fix for me was to open the files in Inkscape and save a copy, and these files are fine.

The original error message said "The SVG file is invalid. Validate it before opening." The ironic thing is that after saving a copy with a new name, the original files will now open inĀ  Illustrator.

Solution 8:[8]

As a complete non-techy, I followed the advice above and opened my SVG in text editor. None of the problems above were in my file so I compared the file to a working SVG file, trialed a few things and discovered that " 0 0 no-repeat at the very end of the code outside of the tag was the culprit! Deleted this and voila! :-)

Solution 9:[9]

Wow, so many different answers! Might as well add my own... This is handled the error in Adobe Illustrator when opening a file downloaded from the internet, might work in other scenarios as well.

I opened the svg in a text editor and noticed that the XML prolog at the beginning did not match a different, working, file. Specifically the non-working one was version 1.1 and did not include the standalone="no" attribute. So the fixed prolog now reads:

<?xml version="1.0" encoding="UTF-8" standalone="no">

Worked for me!

Solution 10:[10]

After opening my svg in a code/text editor, in my case Visual Studio Code I noticed that mine had <DIV id="container"> and </DIV> surrounding the <svg..... > data.

Removing this div tag solved my issue.

Solution 11:[11]

I stumbled on another easy fix by luck: I was about to open an SVG in a text editor, when I noticed that OSX was defaulting SVGs to ImageOptim, an app I use for stripping metadata, etc. So I let that have the file, and a moment later I had a valid SVG file that took up 68% less space on disk.

Solution 12:[12]

I had a similar problem, which was not solved by any of the above mentioned solutions. In the end I solved it by unchecking the box 'Export RDF metadata' when creating the SVG file (in QGIS in this case).

Most likely something in the RDF metadata must have been unreadable for Illustrator, but I didn't manage to figure out what part exactly.