Last active
          February 18, 2021 04:15 
        
      - 
      
- 
        Save HashRaygoza/e686f8c07eb27f61aa7cb4abe0787575 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | File archivo = new File(file); | |
| DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); | |
| // Esto es para agilizar la lectura de archivos grandes | |
| documentBuilderFactory.setNamespaceAware(false); | |
| documentBuilderFactory.setValidating(false); | |
| documentBuilderFactory.setFeature("http://xml.org/sax/features/namespaces", false); | |
| documentBuilderFactory.setFeature("http://xml.org/sax/features/validation", false); | |
| documentBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false); | |
| documentBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); | |
| // constructor de objetos XML | |
| DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); | |
| Document documento = documentBuilder.parse(archivo); | |
| // Esto ayuda al procesamiento | |
| documento.getDocumentElement().normalize(); | |
| StringWriter writer = new StringWriter(); | |
| TransformerFactory tf = TransformerFactory.newInstance(); | |
| Transformer transformer = tf.newTransformer(); | |
| transformer.transform(new DOMSource(documento), new StreamResult(writer)); | |
| String xmlString = writer.getBuffer().toString(); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment