• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2915
  • Last Modified:

Replacement for setTextContent() method (org.w3c.dom.Node) in java 1.4.2

Hello experts,
I was using Java 1.5 in my appl. M writing a program to programatically create an xml file. To add data to the contents of a node i used the setTextContent() method (org.w3c.dom.Node). Now i hve a necessity to migrate to Java 1.4.2 which does not support the following method. Can anybody suggest a replacement method used earlier to add data to the node.

thank you..
0
royalcyber
Asked:
royalcyber
  • 4
  • 3
1 Solution
 
CEHJCommented:
You can use setNodeValue if it's a text node
0
 
royalcyberAuthor Commented:
I tried that.. but m getting not getting the specefied value inside the node. The contents r blank.
0
 
CEHJCommented:
Try

node.appendChild(doc.createTextNode("This is my content"));
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
royalcyberAuthor Commented:
well... ok. That gives me the value of the node, the contents.. But the element tag is missing. Th eone i prev created by using doc.createElement("name"); which resulted in the  <name> tag. So, how do i create the tag and specefy the data of the tag?
0
 
CEHJCommented:
>>But the element tag is missing.

That would have to be called on 'name'

Node name = doc.createElement("name");
name.appendChild(doc.createTextNode("This is my content"));
0
 
royalcyberAuthor Commented:
CEHJ to the rescue again ;-) thank you..
0
 
CEHJCommented:
:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now