Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization 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
Pie
Posts: 20775
30
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
Pie
Posts: 20775
30
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
Pie
Posts: 20775
30
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