problem withgetParentNode()

while retreiving data from xml file

i wrote the code

Node desc3ValueNode = currentDesc3Node.getParentNode();

where currentDesc3Node is a child node

Now when i say

if (desc3ValueNode!=null){

Node desc3NameValueNode = desc3ValueNode.getParentNode();

}

the value of desc3NameValueNode is coming as null .But in xml it has a parent node how this can be solved so that the true parent node value comes

[472 byte] By [amin_rashid] at [2007-9-26 3:14:33]
# 1
Hello Aminur,what is null? When desc3NameValueNode == null, than post (or send) please more code. But when desc3NameValueNode.getNodeValue() == null, then see in documetation, for a Node from typ Element the nodeValue = null, it is correct.Regards Roland
rkunzke at 2007-6-29 11:24:57 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

yes the vale of

desc3NameValueNode is coming null

The function is to set a value in a text node

The nodes are as

desc3ValueNode::<VALUE>Portfolio ,Microfile Bureau &rashid >, Black</VALUE>

And its parent node is

desc3NameValueNode::<NAMEVALUE>

<NAME>Desc1</NAME>

<VALUE>Portfolio ,Microfile Bureau &rashid >, Black</VALUE></NAMEVALUE>

hello 2<NAMEVALUE>

<NAME>Desc1</NAME>

<VALUE>Portfolio ,Microfile Bureau &rashid >, Black</VALUE>

But second time when i am checking for

desc3ValueNode:: it is giving correct value but when i check for its parent node

desc3NameValueNode::it comes as null

amin_rashid at 2007-6-29 11:24:57 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

Hi,

is not easy to see your problem in this codefragment, but note follow:

1.) when:

<xml version="1.0"?>

<tag1>textInTag1

<tag2><textIntag2></tag2>

</tag2>

then:

tag1 and tag2 are Nodes with nodeType == Node.ELEMENT_NODE and nodeValue == null and nodeName == "tag1" or "tag2"

textInTag1 and textInTag2 are Nodes with nodeType == Node.TEXT_NODE and nodeValue == "textInTag1" or "textInTag2"

then also tag1 the parentNode for the other Nodes.

2.)

the char ">" is in XML reserved. Used it not in a Node.

Good Luck. When it not help send me your code with mail.

Roland

rkunzke at 2007-6-29 11:24:57 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...