commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <ralph.go...@dslextreme.com>
Subject Re: [CONFIGURATION] Create configuration out of XML String
Date Thu, 08 Oct 2009 14:03:38 GMT

On Oct 8, 2009, at 4:08 AM, Gaurav Upadhyay wrote:

>
> I have a xml string and need to use commons configuration with it.
>
> How can i create a configuration on it?
>
> Example:
>
> String test = "<?xml version=\"1.0\"
> encoding=\"utf-8\"?><username><firstname>Tom</firstname>
> <lastname>Jay</lastname></username>"
>
> and i just need to create a configuration and access :
>
> config.getString("firstname");
> -- 

I would suggest you give this a try.

ByteArrayInputStream is = new ByteArrayInputStream(test.getBytes());
XMLConfiguration config = new XMLConfiguration();
config.setFileName("test"); // May not be necessary
config.load(is);


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message