1 package de.dhbwloe.campusapp.network;
3 import android.os.Bundle;
4 import android.util.Log;
5 import android.util.Xml;
7 import java.util.ArrayList;
10 * Created by pk910 on 22.01.2016.
12 public class XmlEntry {
13 public static XmlEntry FindXmlEntryByName(XmlEntry root, String name) {
14 if(root.getName().equalsIgnoreCase(name))
16 for(XmlEntry entry : root.getChildren()) {
17 entry = FindXmlEntryByName(entry, name);
24 public static XmlEntry[] FindXmlEntriesByName(XmlEntry root, String name) {
25 Log.i("XMLFind", "Search "+name+" have: "+root.getName());
26 if(root.getName().equalsIgnoreCase(name))
27 return new XmlEntry[] { root };
29 ArrayList<XmlEntry> entries = new ArrayList<XmlEntry>();
30 for(XmlEntry entry : root.getChildren()) {
31 XmlEntry[] centries = FindXmlEntriesByName(entry, name);
32 for(XmlEntry centry : centries)
35 XmlEntry[] entriesArr = new XmlEntry[entries.size()];
36 entriesArr = entries.toArray(entriesArr);
43 private ArrayList<XmlEntry> children = new ArrayList<XmlEntry>();
44 private Bundle attributes = new Bundle();
46 public XmlEntry(String name) {
50 public void setValue(String value) {
54 public String getName() {
58 public String getValue() {
62 public void addChild(XmlEntry child) {
66 public XmlEntry[] getChildren() {
67 XmlEntry childs[] = new XmlEntry[children.size()];
68 childs = children.toArray(childs);
72 public void setAttribute(String name, String value) {
73 attributes.putString(name, value);
76 public void setAttributes(Bundle bundle) {
77 attributes.putAll(bundle);
80 public Bundle getAttributes() {
84 public String getAttribute(String name) {
85 return attributes.getString(name);