Hi, I have to insert text value in one of the child node of the XML file. I am using DOM parser. Can any one help me how to do that. I tried one function but its throwing class cast Exception. Dont know why... Please help me as soon as possible.
SCJP1.5(81%), SCDJWS(94%), next mission SCEA (but need to wait or that)
Element place = (Element) root.getFirstChild(); above line is throwing class cast exception
Let me explain my problem in detail--
above is my sample XML file in click node I have to insert text value and that too one text value in one node at a time.I am using DOM parser . how can I do that . Please help me
SCJP1.5(81%), SCDJWS(94%), next mission SCEA (but need to wait or that)
getFirstChild returns a Node. Element is just one of several possible subclasses of Node; which one is returned in your case? (This is where the getClass().getName() call I mentioned earlier comes in handy.)
Almost always the problem with getFirstChild() is that it is returning a white-space text node that the programmer didn't notice. I didn't look at the details but I notice your XML example does have a lot of white-space text nodes in it.
Hi, While pasting the XML code I got white spaces otherwise I dont have white spaces in my code or you are considering below code as also white space(as there is space indent between Input and Button). Could you please tell me the what are the things I need to consider before parsing an XML file like check for white spaces etc...
please help me regarding this.
SCJP1.5(81%), SCDJWS(94%), next mission SCEA (but need to wait or that)
It seems to me you want to get a Button element that is a child of an Input element. Is that correct? If so then I think you must have overlooked the getElementsByTagName method of the Element class.
Hi, Before I was using Element class but it was throwing classcast exception so now I left that now I ma using Node and using methods getFirstChild(), getNextSibling() etc... but because of that my code becoming lengthy. Please suggest some solution. and tell me where we should use Node and where Element as I am confused in that.
SCJP1.5(81%), SCDJWS(94%), next mission SCEA (but need to wait or that)
The problems of the world fade way as you eat a piece of pie. This tiny ad has never known problems:
a bit of art, as a gift, the permaculture playing cards