Hi,
You could get this working using a
XmlReader
and setting the used namespaces in a
XmlParserContext
/
XmlNamespaceManager
.
Here is the example code I used to test:
string xml = @"<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?>
<svg width=""768"" height=""768"">
<image x=""0"" y=""0"" width=""768"" height=""768"" xlink:href=""images/mask.png""/>
</svg>";
XmlSerializer pageDeserializer = new XmlSerializer(typeof(svg));
using (TextReader txReader = new StringReader(xml))
{
XmlReaderSettings settings = new XmlReaderSettings();
settings.ConformanceLevel = ConformanceLevel.Fragment;
settings.IgnoreWhitespace = true;
settings.IgnoreComments = true;
NameTable nt = new NameTable();
XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);
nsmgr.AddNamespace("xlink", "urn:http://namespaceurl.com");
XmlParserContext ctx = new XmlParserContext(null, nsmgr, null, XmlSpace.None);
XmlReader reader = XmlReader.Create(txReader, settings, ctx);
svg deserialize = (svg) pageDeserializer.Deserialize(reader);
}
Hope this helps.
Best regards and happy coding,
Stops