KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > org > w3c > dom > Node

org.w3c.dom
Interface Node

All Known Subinterfaces:
Attr, CDATASection, CharacterData, Comment, Document, DocumentFragment, DocumentType, Element, Entity, EntityReference, Notation, ProcessingInstruction, Text
All Known Implementing Classes:
IIOMetadataNode
See Also:
Top Examples, Source Code

Node appendChild(Node newChild)
                 throws DOMException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final short ATTRIBUTE_NODE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final short CDATA_SECTION_NODE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Node cloneNode(boolean deep)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final short COMMENT_NODE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


short compareDocumentPosition(Node other)
                              throws DOMException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final short DOCUMENT_FRAGMENT_NODE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final short DOCUMENT_NODE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final short DOCUMENT_POSITION_CONTAINED_BY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final short DOCUMENT_POSITION_CONTAINS
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final short DOCUMENT_POSITION_DISCONNECTED
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final short DOCUMENT_POSITION_FOLLOWING
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final short DOCUMENT_POSITION_PRECEDING
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final short DOCUMENT_TYPE_NODE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final short ELEMENT_NODE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final short ENTITY_NODE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final short ENTITY_REFERENCE_NODE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


NamedNodeMap getAttributes()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


String getBaseURI()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


NodeList getChildNodes()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Object getFeature(String feature,
                  String version)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Node getFirstChild()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Node getLastChild()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


String getLocalName()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


String getNamespaceURI()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Node getNextSibling()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


String getNodeName()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


short getNodeType()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


String getNodeValue()
                    throws DOMException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Document getOwnerDocument()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Node getParentNode()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


String getPrefix()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Node getPreviousSibling()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


String getTextContent()
                      throws DOMException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Object getUserData(String key)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


boolean hasAttributes()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


boolean hasChildNodes()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Node insertBefore(Node newChild,
                  Node refChild)
                  throws DOMException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


boolean isDefaultNamespace(String namespaceURI)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


boolean isEqualNode(Node arg)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


boolean isSameNode(Node other)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


boolean isSupported(String feature,
                    String version)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


String lookupNamespaceURI(String prefix)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


String lookupPrefix(String namespaceURI)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void normalize()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final short NOTATION_NODE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final short PROCESSING_INSTRUCTION_NODE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Node removeChild(Node oldChild)
                 throws DOMException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Node replaceChild(Node newChild,
                  Node oldChild)
                  throws DOMException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1593]Traverse a DOM document using Apache xerces DocumentTraversal API
By Anonymous on 2005/11/04 20:23:08  Rate
//Traverse a DOM document using Apache xerces DocumentTraversal API 
  
  
 public static void usingTraversal ( Document doc )   {  
  
  
 if  ( ! ( doc instanceof DocumentTraversal )  )   {  
   System.out.println ( "Not DocumentTraversal" ) ; 
  }  
  
  
 DocumentTraversal traversal =  ( DocumentTraversal )  doc; 
  
  
 NodeIterator each = traversal.createNodeIterator ( doc,NodeFilter.SHOW_ELEMENT| NodeFilter.SHOW_PROCESSING_INSTRUCTION, null, false ) ; 
  
  
 Node walker=null; 
 while  (  ( walker = each.nextNode (  )  )  != null )   {  
    if  ( walker.getNodeType (  )  == Node.PROCESSING_INSTRUCTION_NODE )   {  
       ProcessingInstruction pi =  ( ProcessingInstruction ) walker; 
       if  ( "aTarget".equalsIgnoreCase ( pi.getTarget (  )  )  )   {  
   //When we find a certain ProcessingInstruction node 
   //replace it with a new ProcessingInstruction node with a different target 
    
   //do something with the data 
   System.out.println ( pi.getData (  )  ) ; 
  
  
   ProcessingInstruction newPI = doc.createProcessingInstruction ( "newTarget", pi.getData (  )  ) ; 
   pi.getParentNode (  ) .replaceChild ( pi, newPI ) ; 
        }  
     }    
      
    if  ( walker.getNodeType (  )  == Node.ELEMENT_NODE )   {  
       NamedNodeMap attributes = walker.getAttributes (  ) ; 
       Attr attr = null; 
       for  ( int i = 0; i  <  attributes.getLength (  ) ; i++ )   {  
           attr =  ( Attr ) attributes.item ( i ) ; 
           //do something with the data 
           System.out.println ( attr.getValue (  )  ) ; 
        }  
  
  
       if  ( walker.getChildNodes (  ) .getLength (  )  == 1 )   {  
           Node aNode = walker.getFirstChild (  ) ; 
           if  ( aNode.getNodeType (  )  == Node.TEXT_NODE )   {  
              //do something with the data 
              System.out.println ( pi.getData (  )  ) ; 
            }  
        }  
    
     }  
  }  
  
  
  }  
 


void setNodeValue(String nodeValue)
                  throws DOMException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[275]Update a XML file
By timlow84 { at } singnet { dot } com { dot } sg on 2003/06/17 05:07:08  Rate
org.w3c.dom.Document domDoc = null; 
       DOMParser parser = new DOMParser (  ) ; 
        
       parser.parse ( new InputSource ( "../webapps/ROOT/security/security_table.xml" )  ) ; 
       domDoc = parser.getDocument (  ) ; 
        
       domDoc.getElementsByTagName ( "Entry" ) .item ( i ) .getFirstChild (  ) .setNodeValue ( formDate ) ; 
       domDoc.getElementsByTagName ( "Entry" ) .item ( i ) .getNextSibling (  ) .setNodeValue ( formRisk ) ; 
       domDoc.getElementsByTagName ( "Entry" ) .item ( i ) .getNextSibling (  ) .setNodeValue ( formDesc ) ; 
       domDoc.getElementsByTagName ( "Entry" ) .item ( i ) .getNextSibling (  ) .setNodeValue ( formAffected ) ; 
    
       DOMBuilder fileBuilder = new DOMBuilder (  ) ; 
       org.jdom.Document jdomDoc = fileBuilder.build ( domDoc ) ; 
       xmlBackup.writeToFile ( "../webapps/ROOT/security/security_table.xml", jdomDoc ) ;


[706]_
By psperncz { at } sagauro { dot } ro on 2004/03/22 05:18:03  Rate
  child = child.getNextSibling  (  ) ; 
     child.setNodeValue  ( "NEWWWWWWWWWWWW" ) ;


void setPrefix(String prefix)
               throws DOMException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void setTextContent(String textContent)
                    throws DOMException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1500]Wrong JavaDoc for setTextContent
By Juan Lanus on 2005/08/01 08:42:49  Rate
The Javadoc for this method is wrong. 
 Looks like the writer copied the get... method docs and forgot to modify it for the set...


Object setUserData(String key,
                   Object data,
                   UserDataHandler handler)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final short TEXT_NODE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags