DOM « XML file « Java I/O Q&A

1. How to ignore whitespace while reading a file to produce an XML DOM

I'm trying to read a file to produce a DOM Document, but the file has whitespace and newlines and I'm trying to ignore them, but I couldn't:

DocumentBuilderFactory docfactory=DocumentBuilderFactory.newInstance();
I see in Javadoc ...

2. Java change and move non-standard XML file

I am using a third party application and would like to change one of its files. The file is stored in XML but with an invalid doctype. When I try to read ...

3. ClassCastException reading XML file

I have the following xml file:

<?xml version="1.0" encoding="UTF-8"?>  
 <c2 id="0001" n="CM" urlget="/at/CsM" urle="/E/login.jsp">
 <c2 id="0002" n="C2M" urlget="/a2t/CsM" urle="/E2/login.jsp">
I'm trying to load c2's attributes this way:
Document d ...

4. content of XML file created by java app dissapears if computer is shut down

I developed a desktop application, which has a class that reads a XML file (using DOM), then performs some operations to the data, and saves the data back to XML (replacing ...

5. javax.xml.transform.TransformerException: (Access is denied)

I am getting exception at last line of code -

Transformer transformer = TransformerFactory.newInstance().newTransformer();
DOMSource xmlSource = new DOMSource(document);
StreamResult result;
File f = new File(sFilePath);
if (f.exists() == false) {
result = new StreamResult(f);
} else ...

6. Remove data from XML file in DOM?

Is there an easy way (perhaps using the DOM api, or other) where I could remove the actual data from an XML file, leaving behind just a kind of template of ...

7. How does file loading in DOM work?

I've been looking at loading XML files with Java and I just can't seem to decipher a certain part of it. I understand that SAX is a streaming mechanism, but when talking ...

8. Parsing XML file with DOM (Java)

I want to parse the following url: As a result I came up with the following method:

public void parseXml2(String URL) {
    DOMParser parser = new ...

9. Cant read data from an XML file using DOM

10. Trying to read an XML file using DOM

12. Update an XML file using DOM

Hi all, I have a question about updating an existing xml file and writing it back. let say that this is the file: 15 25 I wanted to parse this file and append a new property to all and save it back. 15 1.0 ...

14. creating a new XML file using DOM?? plzzz help

do you mean that the DTD should exist and can't be created dynamically? That would be the sensible thing to do. In my opinion having a computer program produce a document with an internal DTD is rather pointless. Just have the program produce a document that is valid according to the DTD and leave out the DTD entirely. Unless you're declaring ...