Package net.htmlparser.jericho

Examples of net.htmlparser.jericho.Attribute


            Attributes atts = element.getAttributes();
           
            if(atts != null && atts.size() > 0) {
              Iterator<Attribute> iter = atts.iterator();
              while (iter.hasNext()) {
                Attribute att = iter.next();
                if (ATT_DISABLED.equalsIgnoreCase(att.getName()) ||
                  ATT_READONLY.equalsIgnoreCase(att.getName()) ||
                  (ATT_TYPE.equalsIgnoreCase(att.getName()) &&
                      TYPE_HIDDEN.equalsIgnoreCase(att.getValue()))) {
                  logger.debug("Removing " + att.getName() + ": " + response.substring(att.getBegin(), att.getEnd()));
                  outputDocument.remove(att);
                  changed = true;
                }
              }
            }
View Full Code Here


                Source source = new Source(responseBody);
                List list = source.getAllStartTags(HTMLElementName.META);
                for (Object aList : list) {
                    StartTag startTag = (StartTag) aList;
                    Attributes attributes = startTag.getAttributes();
                    final Attribute attribute = attributes.get("http-equiv");
                    if (attribute != null && attribute.getValue().equalsIgnoreCase("content-type")) {
                        type = attributes.get("content").getValue().split(";");
                        if (type.length == 2) {
                            contentCharset = type[1].split("=")[1];
                        }
                    }
View Full Code Here

                        }
                        document.insert(element.getBegin(), buf.toString()); // 插入块指令
                    }
                    // ---- 指令属性处理 ----
                    for (int i = 0; i < directiveAttributes.size(); i++) {
                        Attribute attribute = (Attribute) directiveAttributes.get(i);
                        document.remove(new Segment(source, attribute.getBegin() - 1, attribute.getEnd())); // 移除属性
                    }

                    if (attributes != null) {
                        //检查扩展的ifattr指令
                        for (Attribute attribute : attributes) {
                            if (attribute != null) {
                                String name = attribute.getName();
                                if (ifattr.equals(name)) {
                                    String val = attribute.getValue();
                                    String[] arr = val.split(",");
                                    String attrName = arr[0].trim();
                                    String expression = arr[1].trim();

                                    //修改原attribute
                                    Attribute oriattr = attributes.get(attrName);
                                    if (oriattr != null) {
                                        String buf = String.format("#if(%s)%s=\"%s\"#end()", expression, oriattr.getName(), oriattr.getValue());
                                        document.replace(new Segment(source, oriattr.getBegin(), oriattr.getEnd()), buf);
                                        document.remove(new Segment(source, attribute.getBegin(), attribute.getEnd())); // 移除ifattr控制属性
                                    }
                                }
                            }
                        }

                        //检查扩展的setattr指令
                        for (Attribute attribute : attributes) {
                            if (attribute != null) {
                                String name = attribute.getName();
                                if (setattr.equals(name)) {
                                    String val = attribute.getValue();
                                    String[] arr = val.split(",");
                                    String attrName = arr[0].trim();
                                    String expression = arr[1].trim();

                                    //将控制指令直接替换为动态属性赋值
                                    Attribute oriattr = attributes.get(attrName);
                                    String buf = String.format("%s=\"%s\"", attrName, expression);
                                    document.replace(new Segment(source, attribute.getBegin(), attribute.getEnd()), buf);

                                    //如果有已经存在的静态属性,直接删去即可
                                    if (oriattr != null) {
View Full Code Here

TOP

Related Classes of net.htmlparser.jericho.Attribute

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.