Showing posts with label Parsing. Show all posts
Showing posts with label Parsing. Show all posts

Monday, July 6, 2009

Writing DOM to XML File on Disk

Just wrote a small program to write a DOM to an XML on the disk using Xerces. The sample class can be seen here. If you are using maven, don't forget to add xerces dependencies:
        <dependency>
<groupId>xerces</groupId>
<artifactId>xmlParserAPIs</artifactId>
<version>2.6.2</version>
</dependency>
<dependency>
<groupId>apache-xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.9.1</version>
</dependency>

For more details, refer Processing XML with Java by Elliotte Rusty Harold

Thursday, January 15, 2009

Parsing CSV File

I just wanted to read a simple CSV file in the resources folder and parse it in my spring application. A simple class to do the same. csvFileName is a string property injected at runtime.

CSV Reader

Errata: My good friend and colleague Ben has rightly pointed out availability of generic csv parsers that can make life easier. I am exploring Java CSV and Flatpack as suggested by Ben.

Java CSV API
Java CSV Sample