I am trying to use the java XOM libraries but I am having trouble getting them to work the way I want them to. I want to get each element and its attributes from an xml file then use that information to create folders and files on the users computer as part of an installer.

The problem is when I get any child element of the root element I am unable to get the child's attributes or their children. I can't figure it out from the documentation. Here is a link to the documentation of the libraries.http://www.xom.nu/apidocs/

here is the first part of my code for downloading and installing the files but I can't get the information I need past the root element.

function copyDirectory(doc: Document, onlineLocation: String, installLocation: String): Void{
        var data = doc.getRootElement();
        var rootFolder = data.getChild(1);  // I am having the problem with the getChild() command it returns a object that does not allow you to get its attributes or its children.
        var rootOnlineFile = new File(onlineLocation);
        var rootFolderName = rootFolder.getAttributeValue("name");
        var rootFolderHidden = rootFolder.getAttributeValue("hidden");

        var r = 0;
        //Creates the root folder
        while(r < rootFolder.getChildCount()){
            var L1FolderFile = rootFolder.getChild(r);

            if(L1FolderFile.getAttributeValue("type") == "folder"){


Here is the basic xml file I am trying to parse.

<?xml version = "1.0" encoding = "UTF-8"?>
	<info version = "0" releaseDate = "3.21.11" releaseTime = "1815" systemRestartRequired = "false" programRestartRequired = "false" programOffDuringUpdate = "false"/>
	<folder name = "Game Center" hidden = "false" url = "http://kenai.com/projects/resource/downloads/download/GCResourceFiles/" type = "folder" lastUpdated = "">
		<folder name = "Games" hidden = "false" url = "null" type = "folder" lastUpdated = "">
			<folder name = "Panterra" hidden = "false" url = "null" type = "folder" lastUpdated = "">
				<folder name = "data" hidden = "false" url = "null" type = "folder" lastUpdated = "">
					<file url = "http://kenai.com/projects/resource/downloads/directory/GCResourceFiles/FileList.xml" name = "FileList" type = ".xml" size = "null" lastUpdate = "" />
					<file url = "http://kenai.com/projects/resource/downloads/directory/GCResourceFiles/Castle.blend" name = "castle" type = ".blend" size = "null" lastUpdate = "" />
			<folder url = "null" name = "ManInBox" hidden = "false" type = "folder" lastUpdated = "">

Edited by DarkLightning7: n/a

7 Years
Discussion Span
Last Post by DarkLightning7

I have figured out how to access all the information in child elements. First call getChildElements(elementName); then call get(number); in order to access all information in the elements. To access different attributes call getAttributeValue(AttributeName);.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.