[jdom-interest] jdom build a JAva Object with a file XML with morethan one item

Phil Weighill-Smith phil.weighill-smith at volantis.com
Wed Jan 26 13:12:32 PST 2005


Using JDOM you can read this XML file (see http://www.jdom.org/docs/apidocs/org/jdom/input/SAXBuilder.html) into a JDOM Document (see http://www.jdom.org/docs/apidocs/org/jdom/Document.html). This document will have a root node called "applications" (see http://www.jdom.org/docs/apidocs/org/jdom/Document.html#getRootElement()). This root node will have two child elements, both called "application" (see http://www.jdom.org/docs/apidocs/org/jdom/Element.html).
 
Either using the JDOM API (to which these links take you) or using the JDOM XPath API (see http://www.jdom.org/docs/apidocs/org/jdom/xpath/XPath.html) you can traverse this DOM to read the data (attributes, child elements etc.).
 
Hope that helps,
 
Phil :n)

	-----Original Message----- 
	From: Christian Avril [mailto:christian.avril at dpma.finances.gouv.fr] 
	Sent: Wed 26/01/2005 18:17 
	To: jdom-interest at jdom.org 
	Cc: 
	Subject: [jdom-interest] jdom build a JAva Object with a file XML with morethan one item
	
	
	Hello , 
	 
	Have You Please an example with an XML File and more than one item.
	I would build this file in a Java Object. But there are more than one "application"
	See
	<?xml version="1.0" encoding="utf-8"?>
	<applications  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xsi:noNamespaceSchemaLocation="applications.xsd">
	   <application key="appli1">
	  <rule>rule_a</rule>
	        <role>admin</role>
	        <permission>0</permission>
	        <population>allperson
	           <filter>ou=ldapfilter123</filter>
	        </population>
	   </application>
	   <application key="appli1">
	  <rule>rule_u</rule>
	        <role>user</role>
	        <permission>1</permission>
	        <population>users
	            <filter>ou=ldapfilter456</filter>
	        </population>
	   </application>
	   <application key="appli2">
	  <rule>rule_a</rule>
	        <role>admin</role>
	        <permission>2</permission>
	        <population>allperson
	            <filter>ou=ldapfilter789</filter>
	        </population>
	    </application>
	 </applications>
	 
	Thanks 
	 
	Chris





More information about the jdom-interest mailing list