MCPcopy Create free account
hub / github.com/c0ny1/captcha-killer / searchXml

Method searchXml

src/main/java/matcher/impl/XmlMatcher.java:65–110  ·  view source on GitHub ↗
(final Element node,String keyword)

Source from the content-addressed store, hash-verified

63
64
65 protected void searchXml(final Element node,String keyword) {
66 String[] fs = keyword.split("\\.");
67 String current_keyword = fs[0];
68 String attr_name = null;
69 String new_keyword = null;
70
71 if(current_keyword.contains("#")){
72 attr_name = current_keyword.split("#")[1];
73 current_keyword = current_keyword.split("#")[0];
74 }
75
76 if(fs.length != 1) {
77 new_keyword = keyword.replace(current_keyword + ".", "");
78 }else{
79 new_keyword = current_keyword;
80 }
81
82 // 判断是匹配到keyword的头部关键字,否则继续使用原keyword继续递归搜索,直到匹配头部关键字
83 if(node.getName().equals(current_keyword)){
84 if(attr_name != null){
85 final List<Attribute> listAttr = node.attributes();
86 for (final Attribute attr : listAttr) {
87 if(attr.getName().equals(attr_name)){
88 result.add(attr.getValue());
89 }
90 }
91 // 属性不存在子树,所以它肯定是keyword末端,无需在继续递归了。
92 return;
93 }
94
95 // 如果是keyword末尾关键字,则添加到结果,否则继续使用新的关键字递归搜索
96 if(fs.length == 1) {
97 result.add(node.getTextTrim());
98 }else{
99 final List<Element> listElement = node.elements();
100 for (final Element e : listElement) {
101 searchXml(e,new_keyword);
102 }
103 }
104 }else{
105 final List<Element> listElement = node.elements();
106 for (final Element e : listElement) {
107 searchXml(e,keyword);
108 }
109 }
110 }
111
112 protected void buildKeyword(Element node, String val, String keyword){
113 if(keyword == null){

Callers 2

matchMethod · 0.95
matchMethod · 0.95

Calls 1

getNameMethod · 0.80

Tested by 1

matchMethod · 0.76