This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes NullPointerException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "NullPointerException" Watch "NullPointerException" New topic
Author

NullPointerException

shalini gnana
Ranch Hand

Joined: Sep 18, 2007
Posts: 189
I tried to change the content of the attribute in the xml using
DOM.Its throwing nullpointer exception...


This is my xml:


Suraj Berwal
Greenhorn

Joined: Dec 28, 2001
Posts: 26
The problem is you are not using the Document class instance you have created in second line of your main method.

You are creating a new instance of Document class in the changeData() method.


You need to pass the object of the Document class to the changeData() method in your main method. Modify your change Data() method to accpet the Document object in its parameters.

Try and see if it works. Post your output if it doesn't work.

Thanks,
Suraj
shalini gnana
Ranch Hand

Joined: Sep 18, 2007
Posts: 189
Its no throwing any error,now...
But the attribute "value1" is not changing into newValue1..

Thank you...
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
But the attribute "value1" is not changing into newValue1..


Where are you looking? The original file won't be changed unless you write over it - there is no magic link between the DOM and the text file.

Bill
shalini gnana
Ranch Hand

Joined: Sep 18, 2007
Posts: 189
element.setAttribute("value", "newValue1");


I tried to set value to the attribute,but its not getting
edited...Can anyone say,how to edit?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
I guess I am going to have to repeat myself:
Where are you looking? The original file won't be changed unless you write over it - there is no magic link between the DOM and the text file.



Bill
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: NullPointerException