Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

NullPointerException

 
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried to change the content of the attribute in the xml using
DOM.Its throwing nullpointer exception...


This is my xml:


 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its no throwing any error,now...
But the attribute "value1" is not changing into newValue1..

Thank you...
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Willie Smits can speak 40 languages. This tiny ad can speak only one:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic