aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/web
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2013-05-02 22:35:38 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2013-05-02 22:35:38 +1200
commitc53fdd16d37761c77005519b47efef1a61b2c98f (patch)
tree9e5cc22064f94d105b70fe4f1e748fbab9900fcd /src/org/traccar/web
parentb34fe7b41653ddca35d53cff629db044d6c984a0 (diff)
downloadetbsa-traccar-web-c53fdd16d37761c77005519b47efef1a61b2c98f.tar.gz
etbsa-traccar-web-c53fdd16d37761c77005519b47efef1a61b2c98f.tar.bz2
etbsa-traccar-web-c53fdd16d37761c77005519b47efef1a61b2c98f.zip
Fix XML parsing (fix #45)
Diffstat (limited to 'src/org/traccar/web')
-rw-r--r--src/org/traccar/web/Traccar.gwt.xml1
-rw-r--r--src/org/traccar/web/client/model/StateReader.java14
-rw-r--r--src/org/traccar/web/shared/model/XmlParser.java40
3 files changed, 12 insertions, 43 deletions
diff --git a/src/org/traccar/web/Traccar.gwt.xml b/src/org/traccar/web/Traccar.gwt.xml
index 4ae8870..0f71766 100644
--- a/src/org/traccar/web/Traccar.gwt.xml
+++ b/src/org/traccar/web/Traccar.gwt.xml
@@ -7,6 +7,7 @@
<inherits name='com.google.gwt.user.User'/>
<inherits name="com.google.gwt.logging.Logging"/>
+ <inherits name="com.google.gwt.xml.XML"/>
<inherits name='com.sencha.gxt.ui.GXT'/>
<inherits name='org.gwtopenmaps.openlayers.OpenLayers' />
diff --git a/src/org/traccar/web/client/model/StateReader.java b/src/org/traccar/web/client/model/StateReader.java
index 667f474..10ed980 100644
--- a/src/org/traccar/web/client/model/StateReader.java
+++ b/src/org/traccar/web/client/model/StateReader.java
@@ -5,7 +5,10 @@ import java.util.List;
import org.traccar.web.client.ApplicationContext;
import org.traccar.web.shared.model.Position;
-import org.traccar.web.shared.model.XmlParser;
+
+import com.google.gwt.xml.client.Node;
+import com.google.gwt.xml.client.NodeList;
+import com.google.gwt.xml.client.XMLParser;
public class StateReader {
@@ -31,8 +34,13 @@ public class StateReader {
String other = position.getOther();
if (other != null) {
- for (String key : XmlParser.enumerateElements(other)) {
- state.add(new StateItem(key, XmlParser.getElement(other, key)));
+ try {
+ NodeList nodes = XMLParser.parse(other).getFirstChild().getChildNodes();
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node node = nodes.item(i);
+ state.add(new StateItem(node.getNodeName(), node.getFirstChild().getNodeValue()));
+ }
+ } catch (Exception error) {
}
}
diff --git a/src/org/traccar/web/shared/model/XmlParser.java b/src/org/traccar/web/shared/model/XmlParser.java
deleted file mode 100644
index f19c75a..0000000
--- a/src/org/traccar/web/shared/model/XmlParser.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.traccar.web.shared.model;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import com.google.gwt.regexp.shared.MatchResult;
-import com.google.gwt.regexp.shared.RegExp;
-
-public class XmlParser {
-
- public static List<String> enumerateElements(String input) {
- List<String> list = new LinkedList<String>();
-
- RegExp parser = RegExp.compile("<([^/<][^<]*)>", "g");
- MatchResult result = parser.exec(input);
- while (result.getGroupCount() > 0) {
- list.add(result.getGroup(1));
- result = parser.exec(input);
- }
-
- return list;
- }
-
- public static String getElement(String input, String key) {
-
- StringBuilder pattern = new StringBuilder();
- pattern.append("<").append(key).append(">");
- pattern.append("([^<]*)");
- pattern.append("</").append(key).append(">");
-
- RegExp parser = RegExp.compile(pattern.toString());
- MatchResult result = parser.exec(input);
- if (result.getGroupCount() > 0) {
- return result.getGroup(1);
- }
-
- return null;
- }
-
-}