View RSS Feed

Recent Blogs Posts

  1. DOM Elements, Child Elements, and the Node Interface

    by , 04-27-2012 at 05:11 PM
    The root element has children which can be elements, comments, processing instructions, characters etc. You get the children of an element like this:
    Java Code:
    NodeList nodes = element.getChildNodes();
    
    for(int i=0; i<nodes.getLength(); i++){
      Node node = nodes.item(i);
    
      if(node instanceof Element){
        //a child element to process
        Element child = (Element) node;
        String attribute = child.getAttribute("width");
    ...
    Tags: dom elements Add / Edit Tags
    Categories
    DOM