XMLHelper.java :  » XML-UI » xui32 » com » xoetrope » export » Java Open Source

Java Open Source » XML UI » xui32 
xui32 » com » xoetrope » export » XMLHelper.java
package com.xoetrope.export;

import java.io.Reader;
import net.xoetrope.xml.XmlElement;
import net.xoetrope.xml.XmlSource;
import net.xoetrope.xui.XProject;

/**
 *
 * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
 * the GNU Public License (GPL), please see license.txt for more details. If
 * you make commercial use of this software you must purchase a commercial
 * license from Xoetrope.</p>
 * <p> $Revision: 1.6 $</p>
 */
public class XMLHelper
{
  public static XmlElement readXml( XProject currentProject, String path )
  {
    try
    {
      Reader reader = currentProject.getBufferedReader( path, null );
      XmlElement ele = XmlSource.read( reader );
      return ele;
    }
    catch ( Exception e )
    {
      e.printStackTrace();
      return null;
    }
  }
  
  public static int getAttribAsInt( XmlElement ele, String attribName, int defaultValue )
  {
    String value = ele.getAttribute( attribName );
    try
    {
      return Integer.parseInt( value );
    }
    catch ( Exception e )
    {
      return defaultValue;
    }
  }  
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.