diff --git a/core/src/processing/data/XML.java b/core/src/processing/data/XML.java index f18724474..40ca83a7c 100644 --- a/core/src/processing/data/XML.java +++ b/core/src/processing/data/XML.java @@ -355,6 +355,9 @@ public class XML implements Serializable { * @return the first matching element */ public XML getChild(String name) { + if (name.length() > 0 && name.charAt(0) == '/') { + throw new IllegalArgumentException("getChild() should not begin with a slash"); + } if (name.indexOf('/') != -1) { return getChildRecursive(PApplet.split(name, '/'), 0); } @@ -413,6 +416,9 @@ public class XML implements Serializable { * @author processing.org */ public XML[] getChildren(String name) { + if (name.length() > 0 && name.charAt(0) == '/') { + throw new IllegalArgumentException("getChildren() should not begin with a slash"); + } if (name.indexOf('/') != -1) { return getChildrenRecursive(PApplet.split(name, '/'), 0); } diff --git a/core/todo.txt b/core/todo.txt index 6d29a101d..b7a0089b0 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -155,8 +155,7 @@ o 2) we keep getFloat() like it is, and add getFloatContent(), etc. o 3) we deprecate our nice short getFloat/getInt/etc and go with o getXxxxAttribute() and getXxxxContent() methods. X not gonna do getFloatContent() since it's not really any shorter - -_ beginning slash in getChild() threw an NPE +X beginning slash in getChild() threw an NPE async requests Request r = createRequest("http://p5.org/feed/13134.jpg");