Inkscape layers are SVN groups. You save save an SVG file and open it in a text editor, or use the XML Editor within Inkscape Ctrl+Shift+X. A typical (abbreviated) SVG from Inkscape will look like this:
<svg:g id="layer1" inkscape:groupmode="layer" inkscape:label="My Layer 1">
<svg:path [...] />
<svg:g id="layer2" inkscape:groupmode="layer" inkscape:label="My Layer 2">
From this, you can see that:
- Layers are just groups
- Inkscape using a special attribute
inkscape:groupmode to differentiate groups that are "layers"
- The name you give a layer is in the
- If you want to select all layer in an Inkscape SVG, you want
//svg:g[@inkscape:groupmode='layer'] (see gotcha below)
How you extract and use this information will depend on the scripting language.
Gotcha: Inkscape does allow nested layers, but it doesn't look like you can do that in the UI, so most users won't do it. Nesting layers can be done by manually adding the the
groupmode attribute to a group. If you only want top-level layers, be sure to explicitly ask for them, such as