Please join us at the new JavaWorld Q&A Forums. Your existing login will work there. The discussions here are now read-only.


JavaWorld >> XML & Java

Pages: 1
vidsa
stranger


Reged: 09/22/05
Posts: 9
required sample code for reading xml using dom
      #22604 - 10/11/05 06:56 AM

Hi
iam facing the problem reading the xml file using dom parser.

pls help me
can u provide sample code.

thanks
vidsa


Post Extras: Print Post   Remind Me!   Notify Moderator  
robaustin
stranger


Reged: 10/10/05
Posts: 11
Re: required sample code for reading xml using do [Re: vidsa]
      #22618 - 10/11/05 03:02 PM

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;

public final class DocumentFactory {


public static Document newInstance(final InputStream inputStream) {

Document result = null;

try {

final DocumentBuilderFactory factory = DocumentBuilderFactory
.newInstance();

final DocumentBuilder builder = factory.newDocumentBuilder();
result = builder.parse(inputStream);

} catch (Exception e) {
//..
}

return result;
}

}


Post Extras: Print Post   Remind Me!   Notify Moderator  
codefetch
stranger


Reged: 10/14/05
Posts: 6
Re: required sample code for reading xml using dom [Re: vidsa]
      #22731 - 10/14/05 12:06 PM

This codefetch query for "xml dom" found this simple dom xml parsing example from the book Learning Java

--------------------
java.codefetch.com

Search for Java source code snippets from dozens of books!


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1



Extra information
0 registered and 23 anonymous users are browsing this forum.

Moderator:   

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating:
Topic views: 9917

Rate this topic

Jump to

Contact us JavaWorld

Powered by UBB.threads™ 6.5.5