SomeKittens
SomeKittens

Reputation: 39532

SVG image tag not working

I'm playing around with the SVG tutorial here, and can't load an image. XAMPP is giving me an error that says

This XML file does not appear to have any style information associated with it. The document tree is shown below.

I've copypasta'd from the docs, but it still doesn't work. Code below:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="5cm" height="4cm" version="1.1"
     xmlns="localhost" xmlns:xlink= "localhost/svgtest">
    <image xlink:href="My_Image.jpg" x="0" y="0" height="50px" width="50px"/>
</svg>

Googling the error message tells me that the XML is broken somehow, but I haven't changed anything but the locale and image title.

Upvotes: 39

Views: 26136

Answers (1)

Sirko
Sirko

Reputation: 74046

You got the namespaces wrong.

change

xmlns="localhost" xmlns:xlink= "localhost/svgtest"

to

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

Maybe you should have a look at this Namespaces Crash Course by MDN.

Upvotes: 70

Related Questions