Thursday 4 August 2011

Getting the Notations in a DOM Document

      
import java.io.File;

import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Notation;

public class Main {
  public static void main(String[] argvthrows Exception {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setValidating(true);

    factory.setExpandEntityReferences(false);

    Document doc = factory.newDocumentBuilder().parse(new File("filename"));

    NamedNodeMap notations = doc.getDoctype().getNotations();
    for (int i = 0; i < notations.getLength(); i++) {
      Notation notation = (Notationnotations.item(i);

      String notationName = notation.getNodeName();
      String notationPublicId = notation.getPublicId();
      String notationSystemId = notation.getSystemId();
    }
  }
}

   
    
    
    
    
    
  

No comments:

Post a Comment