Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Document : set raw xml (java)

 
jay vas
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 407
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 407
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, I see. You have a String containing XML and you want to parse it into a Document. Like this:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic