-
Notifications
You must be signed in to change notification settings - Fork 0
Home
gklopper edited this page Sep 13, 2010
·
12 revisions
I wanted a really simple xml parser that did the following operations really easily. Read my blog to find out why…
- Easy one line parsing of the xml.
- Easily access any element or list of elements.
- Easily access any attribute in an element.
Usage
So in a nutshell something like this…
InputStream xmlStream = new URL("http://www.somewhere.com/person.xml").openStream()
Element person = new ReallySimpleXmlImpl().parse(xmlStream);
String postCode = person.element("address")
.element("town")
.element("postcode").value().toString();and
String postCode = person.element("address")
.element("town")
.attribute("postcode").value().toString();I also did not want anything like NodeList which does not implement List and thus
List<Element> phoneNumbers = person.elements("phone-numbers");Get it
Binaries
http://github.com/gklopper/Really-Simple-XML/downloadsYou can download the source from git, or get it via maven…
<repositories>
...
<repository>
<id>mvn-repository.googlecode.com</id>
<name>Maven repository on Google code</name>
<url>http://mvn-repository.googlecode.com/svn/trunk/repository</url>
</repository>
...
</repositories><dependencies>
...
<dependency>
<groupId>really-simple-xml</groupId>
<artifactId>really-simple-xml</artifactId>
<version>2.0.1</version>
</dependency>
...
</dependencies>