comment helper function

This commit is contained in:
Adam D. Ruppe 2013-06-04 09:04:00 -04:00
parent 4964425cc3
commit 93be0d1d4f
1 changed files with 18 additions and 0 deletions

18
dom.d
View File

@ -434,6 +434,24 @@ mixin template DomConvenienceFunctions() {
}
}
/// finds comments that match the given txt. Case insensitive, strips whitespace.
Element[] findComments(Document document, string txt) {
return findComments(document.root, txt);
}
/// ditto
Element[] findComments(Element element, string txt) {
txt = txt.strip().toLower();
Element[] ret;
foreach(comment; element.getElementsByTagName("#comment")) {
string t = comment.nodeValue().strip().toLower();
if(t == txt)
ret ~= comment;
}
return ret;
}
// I'm just dicking around with this
struct ElementCollection {