Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Coversion of String data into a xml file  RSS feed

 
mash john
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am trying to convert a String data to a xml file.

I am taking the data from the queue, this data is basically a xml file which is coming in a string format . I have to process it as a xml file and then need to parse it using DOM
The following is the code snippet:

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
File f=new File(message);

Document doc = builder.parse(f);

Note: the variable message is a string data which is nothing but a xml file content

But this way is not working out. Please advice.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's get some things straight first.

You have some XML in a String, and you want to convert it to a DOM Document, right?
It doesn't really have anything to do with files, does it?

This is how you convert XML in a String to a Document object:

If this is not what you're looking for, please explain more cleary what it is you want to do.
[ December 21, 2005: Message edited by: Jesper de Jong ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!