Does XMLConfiguration in Apache common support CDATA?
-
31-05-2021 - |
سؤال
I'am using Configuration 1.6.
I hava a xml file, like
<property>
<name>sql</name>
<value><![CDATA[select a, b from c]]></value>
</property>
I wish to get "select a, b from c" as a whole string, but i get "select a" and "b from c" as List instead.
You may suggest I join the string's with commas, but somewhere else in my project depends on this property.
المحلول
Change the property of PropertiesConfiguration object like this:
AbstractConfiguration.setListDelimiter(0);
Setting the delimiter to 0 will disable value splitting completely.
That should work.
نصائح أخرى
Using commons configuration 1.9 it is recommend to use:
config = new XMLConfiguration();
config.setListDelimiter((char) 0);
config.setDelimiterParsingDisabled(true);
config.setAttributeSplittingDisabled(true);
config.load(resource);
لا تنتمي إلى StackOverflow