add check to make sure preceding slash not used w/ getChild

This commit is contained in:
benfry
2012-12-16 20:40:19 +00:00
parent c677e2d443
commit 826851f461
2 changed files with 7 additions and 2 deletions

View File

@@ -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);
}