Ribbon Addin - External XML

Phenom
Phenom

Regarding the Ribbon DemoAddin from Jason, has anybody tried using an external XML file instead of the one in the resources.

 

The current version uses:

Me.LoadXml(assembly, _embeddedResourceName)

 

I tried using the other override with a single argument which is a string but it does not appear to be an XML filename:

Private Const _embeddedResourceName As String = "c:\Temp\Ribbon3DEnv.xml"

Me.LoadXml( _embeddedResourceName)

 

 

Then I tried using:

Dim xmlDoc As New XmlDocument()
xmlDoc.Load(_embeddedResourceName)
Dim xmlRibbon As String = xmlDoc.InnerText
Me.LoadXml(xmlRibbon)

 

This too is not working. The error is the root node is not found or present.

 

Is there an easy way to use an external XML file for the ribbon definition instead of the one embedded in the project resources ?

 

Thank you.

 

~Tushar

 

 

2 REPLIES

Re: Ribbon Addin - External XML

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Tushar,

 

Here is how to do it in C#.

 

var xml = System.IO.File.ReadAllText(@"c:\Temp\Ribbon3DEnv.xml");
this.LoadXml(xml);

The xml parameter is the actual XML text. Using this overload, the text can come from anywhere.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: Ribbon Addin - External XML

Phenom
Phenom

Thanks a ton @jnewell

   

I knew it would either be the XML filename or the contents but got carried away with the InnerXML and such stuff overlooking the simple IO.File to read the text within.

  

~Tushar