I feel like this should be easier than it is but I can't seem to get it straight. Here is my test case.
Imports <xmlns="http://www.w3.org/2000/svg">
Public Sub Test()
Dim doc As XDocument = XDocument.Load("input.svg")
Dim svg As XElement = doc.Elements.First
svg.Add(<text>
<tspan>Some Text</tspan>
</text>)
svg.Save("output.svg")
End Sub
the input xml
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg">
<g id="layer4" >
</g>
</svg>
What I get is the following for output,
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg">
<g id="layer4"></g>
<text xmlns="http://www.w3.org/2000/svg">
<tspan>Some Text</tspan>
</text>
</svg>
Why doesn't the new text element see that it's using the default namespace and leave off the xmlns? If I leave off the Imports <xmlns="http://www.w3.org/2000/svg">
statement, I get an empty namespace xmlns=""
on the text element.