/** * @see org.htmlparser.Tag#getAttribute(java.lang.String) */ public String getAttribute(String arg0) { return m_decorated.getAttribute(arg0); }
/** * @see org.htmlparser.Tag#getAttribute(java.lang.String) */ public String getAttribute(String arg0) { return m_decorated.getAttribute(arg0); }
/** * @see org.htmlparser.Tag#getAttribute(java.lang.String) */ public String getAttribute(String arg0) { return m_decorated.getAttribute(arg0); }
/** * Look up an attribute's value by Namespace name. * * <p>See {@link #getValue(int) getValue(int)} for a description * of the possible values.</p> * * @param uri The Namespace URI, or the empty String if the * name has no Namespace URI. * @param localName The local name of the attribute. * @return The attribute value as a string, or null if the * attribute is not in the list. */ public String getValue (String uri, String localName) { return (mTag.getAttribute (localName)); }
@Override public boolean accept(Node node) { if (!(node instanceof Tag)) return false; final Tag tag = (Tag) node; if (tag.getAttribute("id") == null) return false; if (!tag.getAttribute("id").equals(id)) return false; return true; } }
@Override public boolean accept(Node node) { if (!(node instanceof Tag)) return false; final Tag tag = (Tag) node; if (tag.getAttribute("name") == null) return false; if (!tag.getAttribute("name").equals(name)) return false; return true; } }
public boolean accept (Node node) { if (node instanceof Tag && ((Tag) node).getAttribute (attrib) != null) if (rel != null && !rel.matcher (((Tag) node).getAttribute (attrib)).find ()) return (false); else return (true); else return (false); } }
public boolean accept(Node node) { if (node instanceof Tag && ((Tag)node).getAttribute(attrib) != null) if (rel != null && !rel.matcher(((Tag)node).getAttribute(attrib)).find()) return false; else return true; else return false; } }
/** * 处理概览标签,如果是分页概览,记录本信息,系统需要将每个页面都 * 发布出来,并且需要获取分页标签的相关属性,包括每页记录数 * @param tag */ protected void processOutlineTag(Tag tag) { String _isList = tag.getAttribute("isList"); if(_isList != null && _isList.equalsIgnoreCase("false")) isList = false; if(!isList) { String _maxPageItems = tag.getAttribute("maxPageItems"); } }
private boolean renderNone(final Tag tag) { String renderAttributeName = ehtAttributePrefix + "render"; String renderValue = tag.getAttribute(renderAttributeName); if (renderValue == null) { return false; } return HTMLTemplatingUtil.attributeConstantEquals("none", renderValue.trim()) || "false".equalsIgnoreCase(renderValue.trim()); }
/** Should a contents of this tag be kept intact? */ private boolean isIntactTag(Tag tag) { String tagname = tag.getTagName(); return tagname.equals("!DOCTYPE") || tagname.equals("STYLE") || tagname.equals("SCRIPT") || tagname.equals("OBJECT") || tagname.equals("EMBED") || (tagname.equals("META") && "content-type".equalsIgnoreCase(tag.getAttribute("http-equiv"))); }
public boolean accept(Node node) { if (node instanceof Tag) { Tag tag = (Tag) node; String name = tag.getTagName().toUpperCase(); if (name.equals("A") || name.equals("LINK") || name.equals("AREA")) { if (tag.getAttribute("href") != null) { String rel = tag.getAttribute("rel"); if (rel == null) { return true; } rel = rel.toLowerCase(); return rel.indexOf("nofollow") == -1 && !rel.equals("stylesheet"); } } } return false; }
public void visitTag(Tag tag) { if (tag.getRawTagName().equalsIgnoreCase("img")) { String imageValue = tag.getAttribute("src"); if (imageValue.contains("base64")) { String contentId = getContentId(); tag.setAttribute("src", "cid:" + contentId); base64ImagesMap.put(contentId, imageValue.substring(imageValue.indexOf("base64") + 7, imageValue.length())); } } }
Parser parser = new Parser(url); PageMeta pageMeta = new PageMeta(); pageMeta.setUrl(url); NodeList meta = parser.parse(new TagNameFilter("meta")); for (SimpleNodeIterator iterator = meta.elements(); iterator.hasMoreNodes(); ) { Tag tag = (Tag) iterator.nextNode(); if ("og:image".equals(tag.getAttribute("property"))) { pageMeta.setImageUrl(tag.getAttribute("content")); } if ("og:title".equals(tag.getAttribute("property"))) { pageMeta.setTitle(tag.getAttribute("content")); } if ("og:description".equals(tag.getAttribute("property"))) { pageMeta.setDescription(tag.getAttribute("content")); } }
@Override public void visitTag(Tag tag) { if (isParagraphTag(tag) && text) { endup(); } if ("PARAM".equals(tag.getTagName()) && "Name".equalsIgnoreCase(tag.getAttribute("name"))) { maybeTranslateAttribute(tag, "value"); } queuePrefix(tag); }
/** * 处理style属性中应用的链接和图片,对于有些图片已经用<cms:uri>标签处理过时,是不需要再进行处理的 * @param tag */ protected void processStylePropertyOfTag(Tag tag) { String style = tag.getAttribute("style"); int linkhandletype = needProcessStyleAtrribute(style); if(linkhandletype == LINK_NO_PARSER_NO_DISTRIBUTE) return ; style = this.handleStyleCode(style); if(style != null) tag.setAttribute("style",style); }
Parser parser = new Parser("http://www.yahoo.com/"); NodeList list = parser.parse(new TagNameFilter("IMG")); for ( SimpleNodeIterator iterator = list.elements(); iterator.hasMoreNodes(); ) { Tag tag = (Tag) iterator.nextNode(); System.out.println(tag.getAttribute("src")); }
private static String getMeta(NodeList nodeList, String name, boolean httpEquiv) { NodeFilter filter = new AndFilter( new NodeClassFilter(MetaTag.class), new AttributeNodeFilter(httpEquiv ? "http-equiv" : "name", name)); NodeList nodes = nodeList.extractAllNodesThatMatch(filter, true); if (nodes.size() > 0) { Tag tag = (Tag) nodes.elementAt(0); return tag.getAttribute("content"); } return null; }
public String getFieldValue(PageData pageData) { String lang = pageData.getHeader(LANG_HEADER); if (lang == null) { lang = HtmlParserUtils.getHttpEquiv(pageData.getNodes(), LANG_HEADER); if (lang == null) { NodeFilter filter = new AttributeNodeFilter(LANG_ATTRIBUTE); NodeList nodes = pageData.getNodes().extractAllNodesThatMatch(filter, true); if (nodes.size() > 0) { Tag tag = (Tag) nodes.elementAt(0); lang = tag.getAttribute(LANG_ATTRIBUTE); } } } return lang; }
/** * If the attribute of the tag is not empty, it translates it as a separate * segment. * * @param tag * the tag object * @param key * the name of the attribute */ protected void maybeTranslateAttribute(Tag tag, String key) { String attr = tag.getAttribute(key); if (attr != null) { String comment = OStrings.getString("HTMLFILTER_TAG") + " " + tag.getTagName() + " " + OStrings.getString("HTMLFILTER_ATTRIBUTE") + " " + key; String trans = filter.privateProcessEntry(HTMLUtils.entitiesToChars(attr), comment); tag.setAttribute(key, HTMLUtils.charsToEntities(trans, filter.getTargetEncoding(), sShortcuts)); } }