tags:

views:

49

answers:

1
Q: 

Spring.net

How do you set a value of an xml property?

This is what I've tried with no succes:

<property name="Resources" value="&#60;resources/&#62;"/>

Resources is an XmlDocument field.

+1  A: 

Just to clarify: This property is on an object that has a field that is an XmlDocument, and you want it to be initialized to an empty XmlDocument with the root element "resources".

XmlDocuments aren't always the easiest objects to work with, especially when it comes to construction.

Spring for sure won't know how to turn a string into an XmlDocument.

You might find it easier to use code to generate the XmlDocument you want. For example, create a static helper method that generates the XmlDocument, and set the value of the property by invoking that method.

Another (kludge-y) option is to have a "helper" property that deals with xml as string. For example, a property called "_ResourcesXml" which you would set to null or "". The property would then construct the XmlDocument and set the backing field for the Resources Property. Similarly, reading _ResourcesXml could return Resources.OuterXml.

Nader Shirazie