• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Coversion of String data into a xml file

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic