org.htmlparser.Tag.getAttribute()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(156)

本文整理了Java中org.htmlparser.Tag.getAttribute()方法的一些代码示例,展示了Tag.getAttribute()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tag.getAttribute()方法的具体详情如下:
包路径:org.htmlparser.Tag
类名称:Tag
方法名:getAttribute

Tag.getAttribute介绍

[英]Returns the value of an attribute.
[中]返回属性的值。

代码示例

代码示例来源:origin: com.bbossgroups.pdp/pdp-cms

/**
 * @see org.htmlparser.Tag#getAttribute(java.lang.String)
 */
public String getAttribute(String arg0) {
  return m_decorated.getAttribute(arg0);
}

代码示例来源:origin: org.opencms/opencms-solr

/**
 * @see org.htmlparser.Tag#getAttribute(java.lang.String)
 */
public String getAttribute(String arg0) {
  return m_decorated.getAttribute(arg0);
}

代码示例来源:origin: org.opencms/opencms-core

/**
 * @see org.htmlparser.Tag#getAttribute(java.lang.String)
 */
public String getAttribute(String arg0) {
  return m_decorated.getAttribute(arg0);
}

代码示例来源:origin: com.bbossgroups/bboss-htmlparser

/**
 * 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));
}

代码示例来源:origin: com.rogiel.httpchannel/httpchannel-util

@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;
  }
}

代码示例来源:origin: com.rogiel.httpchannel/httpchannel-util

@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;
  }
}

代码示例来源:origin: org.htmlparser/htmlparser

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);
  }
}

代码示例来源:origin: com.bbossgroups/bboss-htmlparser

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;
  }
}

代码示例来源:origin: com.bbossgroups.pdp/pdp-cms

/**
 * 处理概览标签,如果是分页概览,记录本信息,系统需要将每个页面都
 * 发布出来,并且需要获取分页标签的相关属性,包括每页记录数
 * @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");
  }        
}

代码示例来源:origin: org.everit.templating/org.everit.templating.html

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());
}

代码示例来源:origin: omegat-org/omegat

/** 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")));
}

代码示例来源:origin: riotfamily/riot

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;
}

代码示例来源:origin: CloudSlang/cs-actions

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()));
    }
  }
}

代码示例来源:origin: stackoverflow.com

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"));
   }
 }

代码示例来源:origin: omegat-org/omegat

@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);
}

代码示例来源:origin: com.bbossgroups.pdp/pdp-cms

/**
 * 处理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);		
}

代码示例来源:origin: stackoverflow.com

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"));
}

代码示例来源:origin: riotfamily/riot

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;
}

代码示例来源:origin: riotfamily/riot

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;
}

代码示例来源:origin: omegat-org/omegat

/**
 * 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));
  }
}

相关文章