add support for getting from name of element in fscript

This commit is contained in:
Wirlaburla 2024-07-21 18:40:18 -05:00
parent 7b7d4a206e
commit acd1f0dfe8

View File

@ -288,6 +288,11 @@ public class Rizzo {
id = tag.substring(tag.indexOf("#")+1); id = tag.substring(tag.indexOf("#")+1);
tag = tag.substring(0, tag.indexOf("#")); tag = tag.substring(0, tag.indexOf("#"));
} }
String name = "";
if (tag.contains("$")) {
name = tag.substring(tag.indexOf("$")+1);
tag = tag.substring(0, tag.indexOf("$"));
}
if (id.length() > 0) { if (id.length() > 0) {
NodeList ns; NodeList ns;
if (parent instanceof Document document) if (parent instanceof Document document)
@ -301,6 +306,19 @@ public class Rizzo {
break; break;
} }
} }
} else if (name.length() > 0) {
NodeList ns;
if (parent instanceof Document document)
ns = document.getChildNodes();
else
ns = ((Element)parent).getChildNodes();
for (int i = 0; i < ns.getLength(); i++) {
Node n = ns.item(i);
if (((Element)n).getAttribute("name").equals(name)) {
newParent = (Element)n;
break;
}
}
} else { } else {
if (parent instanceof Document document) if (parent instanceof Document document)
newParent = document.getElementsByTagName(tag).item(index); newParent = document.getElementsByTagName(tag).item(index);