I am fighting with a foreignObject to add to my svg. I was able to do editing original svg file, but not through c#
Here my foreignObject to add, after :
<foreignObject xmlns="http://www.w3.org/2000/svg" x="90.12" y="32.37" height="20px" width="50px">
<a xmlns="http://www.w3.org/1999/xhtml" style="color:white; font-size:4px; text-decoration-line: none; background-color:red" href="http://www.google.it">GV36LV04-M1000021</a>
</foreignObject>
I was trying in this way, but nothing appear (Edge):
XNamespace ns_xhtml = "http://www.w3.org/1999/xhtml";
XElement fo = new XElement(ns + "foreignObject");
fo.Add(new XAttribute("x", e.x.ToString().Replace(",", ".")));
fo.Add(new XAttribute("y", (e.y - 14).ToString().Replace(",",".")));
fo.Add(new XAttribute("height", "100px"));
fo.Add(new XAttribute("widht", "100px"));
XElement a = new XElement(ns_xhtml + "a");
a.SetAttributeValue("style", "color:white; font-size:4px; text-decoration-line: none; background-color:red");
a.SetAttributeValue("href", "http://www.google.it");
a.SetValue(e.valore);
fo.Add(a);
doc.Root
.DescendantsAndSelf()
.Elements()
.Single(d => d.Name.LocalName == "defs")
.AddAfterSelf(fo);
I noticed that with my code doesn' t appear xmlns attributes ONLY in foreingObject even if it is in VS object (see image below)
What to fix?
Thanks a lot!
