- priority: 5 --> 7
Hello.
First of all, thank you for your contribution: this saved me my time.
I have a request related to the RtmData class: I'm currently developing on Android, and it seems that the "Node.getNextSibling()" is buggy (not confirmed, see http://groups.google.com/group/android-developers/browse_thread/thread/78806f277b55dbff\).
Would it be possible that you changed the methods "child" and "children" (if you want to, I can do that but you need to) of the class, with the following patch (in appendix), which only consists in iterating over the child nodes via the "NodeList", instead of using the Node.getNextSibling()" method?
Thank you very much in advanced.
Regards,
Edouard
--- RTM Java API/src/com/mdt/rtm/data/RtmData.java (revision 5)
+++ RTM Java API/src/com/mdt/rtm/data/RtmData.java (working copy)
@@ -29,6 +29,7 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
/**
*
@@ -41,23 +42,31 @@
public RtmData() {
}
- protected Element child(Element elt, String nodeName) {
- Node child = elt.getFirstChild();
- while (child != null) {
- if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals(nodeName)) { return (Element)child; }
- child = child.getNextSibling();
+ protected Element child(Element elt, String nodeName)
+ {
+ NodeList childNodes = elt.getChildNodes();
+ for (int index = 0; index < childNodes.getLength(); index++)
+ {
+ Node child = childNodes.item(index);
+ if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals(nodeName))
+ {
+ return (Element) child;
+ }
}
return null;
}
- protected List<Element> children(Element elt, String nodeName) {
+ protected List<Element> children(Element elt, String nodeName)
+ {
List<Element> result = new ArrayList<Element>();
- Node child = elt.getFirstChild();
- while (child != null) {
- if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals(nodeName)) {
- result.add((Element)child);
+ NodeList childNodes = elt.getChildNodes();
+ for (int index = 0; index < childNodes.getLength(); index++)
+ {
+ Node child = childNodes.item(index);
+ if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals(nodeName))
+ {
+ result.add((Element) child);
}
- child = child.getNextSibling();
}
return result;
}