aspose file tools*
The moose likes XML and Related Technologies and the fly likes Document : set raw xml (java) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Document : set raw xml (java)" Watch "Document : set raw xml (java)" New topic
Author

Document : set raw xml (java)

jay vas
Ranch Hand

Joined: Aug 30, 2005
Posts: 407
Hi guys : Im trying to set the text in an XML document
in jave using the default java xml implementation (org.w3c.dom.)

Its not working ? I just want to set the raw xml text.

This is driving me crazy please help !???
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18651
    
    8

An XML document can't consist of only text. It has to have a root element. That's why it's "not working", as you put it. Now if you went to the root element of the document and tried to set its content to some text, that probably wouldn't throw any exceptions.
jay vas
Ranch Hand

Joined: Aug 30, 2005
Posts: 407
Thanks !

So then is there any simple way in the java document api way to go from raw text (a String) to a Document object without a file name ?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18651
    
    8

Document objects don't have a file name. I don't understand this question at all. Perhaps you could explain what you are really trying to do.
jay vas
Ranch Hand

Joined: Aug 30, 2005
Posts: 407
Thanks again. Well its pretty simple. I want to create a create a Document object which represents a string...I want to be able to do something like this...

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18651
    
    8

Oh, I see. You have a String containing XML and you want to parse it into a Document. Like this:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Document : set raw xml (java)