• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Removing node/element from DOM

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I came across this problem where I cant remove element from the document.

Here is my code.



Basically I am reading XML file of another website and putting it in a string and parsing it. Now to implement a search functionality, I need to get rid of an element.

I tried it the following way as suggest by a website while googling,



It removes stuff from the NodeList when I do a out.println() before and after this code to verify, but document remains intact when I print it out (using xsl to format it and Transformer). But thats what I expected anyway.

I simply dont know how to remove an element from the actual DOM document. Any ideas anyone?

Cheers for looking at it.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please take the time to choose the correct forum for your posts. This forum is for questions on JSP. For more information, please read this.

This post has been moved to a more appropriate forum.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A little more detail would be helpful. From what you've posted it appears you are trying to delete the second "name" element from an XML document, but that's all I can tell. Sample input document? Source code? Resulting output?
 
Ulrich Von Litchtenstein
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Please take the time to choose the correct forum for your posts. This forum is for questions on JSP. For more information, please read this.

This post has been moved to a more appropriate forum.



Sorry, I am doing all this in a JSP page hence it was put here. Its one of those codes that you can put into normal java or JSP.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As such, it is not a JSP question. Thanks.
 
Ulrich Von Litchtenstein
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:A little more detail would be helpful. From what you've posted it appears you are trying to delete the second "name" element from an XML document, but that's all I can tell. Sample input document? Source code? Resulting output?



Hi Paul,

The XML file is massive, but its something like this



Basically I am trying to remove one of the name element.

If i do document.removeChild("name"); then the compiler wouldnt know which "name" I am trying remove. So I put it in a nodelist which will index all the names but that too didn't work.

 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulrich Von Litchtenstein wrote:Sorry, I am doing all this in a JSP page hence it was put here. Its one of those codes that you can put into normal java or JSP.



Yes, well you might be better off to just write a plain old Java application to test your code. You're probably finding that a JSP is not a very good testing environment.
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulrich Von Litchtenstein wrote:
Basically I am trying to remove one of the name element.

If i do document.removeChild("name"); then the compiler wouldnt know which "name" I am trying remove. So I put it in a nodelist which will index all the names but that too didn't work.



If it didn't work, then you should try doing something differently.

You haven't said in what way it didn't work and you still haven't posted a piece of code that exhibits the problem. There's not much anybody can do until you come up with something specific. Preferably specific input, code which produces incorrect output, explanation of why it's incorrect. That shouldn't be hard as your requirement is quite simple.
 
permaculture is a more symbiotic relationship with nature so I can be even lazier. Read tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic