01: package com.xoetrope.export;
02:
03: import java.io.Reader;
04: import net.xoetrope.xml.XmlElement;
05: import net.xoetrope.xml.XmlSource;
06: import net.xoetrope.xui.XProject;
07:
08: /**
09: *
10: * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
11: * the GNU Public License (GPL), please see license.txt for more details. If
12: * you make commercial use of this software you must purchase a commercial
13: * license from Xoetrope.</p>
14: * <p> $Revision: 1.6 $</p>
15: */
16: public class XMLHelper {
17: public static XmlElement readXml(XProject currentProject,
18: String path) {
19: try {
20: Reader reader = currentProject
21: .getBufferedReader(path, null);
22: XmlElement ele = XmlSource.read(reader);
23: return ele;
24: } catch (Exception e) {
25: e.printStackTrace();
26: return null;
27: }
28: }
29:
30: public static int getAttribAsInt(XmlElement ele, String attribName,
31: int defaultValue) {
32: String value = ele.getAttribute(attribName);
33: try {
34: return Integer.parseInt(value);
35: } catch (Exception e) {
36: return defaultValue;
37: }
38: }
39: }
|