?
Solved

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

Posted on 2006-05-26
7
Medium Priority
?
2,587 Views
Last Modified: 2008-01-09
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
Comment
Question by:royalcyber
  • 4
  • 3
7 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 16771867
You can use setNodeValue if it's a text node
0
 

Author Comment

by:royalcyber
ID: 16771905
I tried that.. but m getting not getting the specefied value inside the node. The contents r blank.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16771912
Try

node.appendChild(doc.createTextNode("This is my content"));
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:royalcyber
ID: 16772030
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
 
LVL 86

Accepted Solution

by:
CEHJ earned 750 total points
ID: 16772059
>>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
 

Author Comment

by:royalcyber
ID: 16772076
CEHJ to the rescue again ;-) thank you..
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16772089
:-)
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month14 days, 4 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question