Create SVG from XmlDocument

Jul 24, 2009 at 8:30 PM

Hi,

at the moment, I try to load an XmlDocument using the Resources class, and open this XmlDocument as SVG. My code looks like this:

 

XmlDocument xmlDocument = new XmlDocument();
xmlDocument.LoadXml(Resources.ErrorImage);
SvgDocument svg =
    SvgDocument.Open(xmlDocument);

XmlDocument xmlDocument = new XmlDocument();
xmlDocument.LoadXml(Resources.ErrorImage);
SvgDocument svg = SvgDocument.Open(xmlDocument);

Basically, the XmlDocument is loaded correctly, and it contains SVG content. But the Open method returns null. Any idea, what might be wrong?
Cheerio,
Golo

Jul 24, 2009 at 9:19 PM

BTW: If I load exactly the same file directly from disk instead of loading it as a resource, everything works fine. So it's obviously no problem with the file's content.

Coordinator
Jul 25, 2009 at 12:05 AM

You know, it sounds like you've used the latest version from the releases page where the Open(XmlDocument) method wasn't implemented yet unfortunately.

If you download the latest source code and compile it the Open(XmlDocument) method will be implemented.

If you don't want to do that there is another option:

var doc = SvgDocument.Open(Resources.ResourceManager.GetStream("My.Full.Namespace.ErrorImage.svg"))*

It's not as pretty as the current option but it should work.

Let me know how you get on.

Cheers,
Scriv

* - I think you'll need the full namespace plus the name of the file (& extension) in there but it might work with just the file name & extension; I don't think I've used that particular API before.

Jul 25, 2009 at 4:42 AM
Hi Dave,

thanks again for helping that fast! It works using your approach, I have used the GetStream variant.

Cheerio,


Golo


Von: davescriven <notifications@codeplex.com>
Gesendet: Samstag, 25. Juli 2009 01:04
An: Golo Roden <webmaster@goloroden.de>
Betreff: Re: Create SVG from XmlDocument [svg:63472]

From: davescriven

You know, it sounds like you've used the latest version from the releases page where the Open(XmlDocument) method wasn't implemented yet unfortunately.

If you download the latest source code and compile it the Open(XmlDocument) method will be implemented.

If you don't want to do that there is another option:

var doc = SvgDocument.Open(Resources.ResourceManager.GetStream("My.Full.Namespace.ErrorImage.svg"))*

It's not as pretty as the current option but it should work.

Let me know how you get on.

Cheers,
Scriv

* - I think you'll need the full namespace plus the name of the file (& extension) in there but it might work with just the file name & extension; I don't think I've used that particular API before.