• 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

DOM Tree supported by JSP

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I am making a DOM tree, which will be supported by multiple JSP documents. Thus allowing an xml file to be made.

I am aware of how to set up the attribute, as the following example demonstrates:

//Create an element for member
//Place the <member> element underneath the <members> element in the tree
Element memberElement = document.createElement("member");
memberElement.setAttribute("id", idNum);
rootElement.appendChild(memberElement);

How ever, if we have an <address> element and we want to have "types" : "home" "work" and "postal" how can we do that?

I think it can be done the following way:

Element addressElement = document.createElement("address");
memberElement.setType("home", "work", "postal" );
memberElement.appendChild(addressElement);

please tell me if my "setType" is correct or not. Ive researched fair bit but im unable to find a solution. If its incorrect what shud be done to set "types" of an element.

Thanks,
S Ali
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even though you are using DOM in a JSP, nothing to do with the problem is specific to JSPs. Moving this post to the "XML and related technologies" forum.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you elaborate a bit on what do you want to accomplish with "setType()" (which is not part of the org.w3c.dom.Element API, by the way)?
 
Sana Ali
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
actually,
it shud be setAttribute.

Im unaware of how to set more than 1 attribute
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sana Ali:
Im unaware of how to set more than 1 attribute


By calling setAttribute() twice with different arguments like so:
 
Hey! Wanna see my flashlight? It looks like this 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