org.htmlparser.Parser.elements()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(120)

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

Parser.elements介绍

[英]Returns an iterator (enumeration) over the html nodes. org.htmlparser.nodes can be of three main types:

  • org.htmlparser.nodes.TagNode
  • org.htmlparser.nodes.TextNode
  • org.htmlparser.nodes.RemarkNode
    In general, when parsing with an iterator or processing a NodeList, you will need to use recursion. For example: <<$0$>>
    [中]返回html节点上的迭代器(枚举)。组织。HTMLPasser。节点可以有三种主要类型:
    *组织。HTMLPasser。节点。标记节点
    *组织。HTMLPasser。节点。文本节点
    *组织。HTMLPasser。节点。RemarkNode
    通常,当使用迭代器进行解析或处理节点列表时,需要使用递归。例如:<<$0$>>

代码示例

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

/**
 * Assign the underlying node filter for this wrapper.
 * @param filter The filter to wrap.
 * @param context The parser to use for conditioning this filter.
 * Some filters need contextual information to provide to the user,
 * i.e. for tag names or attribute names or values,
 * so the Parser context is provided. 
 */
public void setNodeFilter (NodeFilter filter, Parser context)
{
  Set set;
  mFilter = (TagNameFilter)filter;
  set = new HashSet ();
  context.reset ();
  try
  {
    for (NodeIterator iterator = context.elements (); iterator.hasMoreNodes (); )
      addName (set, iterator.nextNode ());
  }
  catch (ParserException pe)
  {
    // oh well, we tried
  }
  for (Iterator iterator = set.iterator (); iterator.hasNext (); )
    mName.addItem (iterator.next ());
  mName.setSelectedItem (mFilter.getName ());
}

代码示例来源:origin: deas/alfresco

PrototypicalNodeFactory factory = new PrototypicalNodeFactory();
parser.setNodeFactory(factory);
NodeIterator itr = parser.elements();
processNodes(buf, itr, false, overrideDocumentType);
PrototypicalNodeFactory factory = new PrototypicalNodeFactory();
parser.setNodeFactory(factory);
NodeIterator itr = parser.elements();
processNodes(buf, itr, true);

代码示例来源:origin: org.alfresco.surf/spring-webscripts

PrototypicalNodeFactory factory = new PrototypicalNodeFactory();
parser.setNodeFactory(factory);
NodeIterator itr = parser.elements();
processNodes(buf, itr, false, overrideDocumentType);
PrototypicalNodeFactory factory = new PrototypicalNodeFactory();
parser.setNodeFactory(factory);
NodeIterator itr = parser.elements();
processNodes(buf, itr, true);

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

try
  for (NodeIterator iterator = context.elements (); iterator.hasMoreNodes (); )
    addAttributes (set, iterator.nextNode ());

代码示例来源:origin: org.springframework.extensions.surf/spring-webscripts

PrototypicalNodeFactory factory = new PrototypicalNodeFactory();
parser.setNodeFactory(factory);
NodeIterator itr = parser.elements();
processNodes(buf, itr, false, overrideDocumentType);
PrototypicalNodeFactory factory = new PrototypicalNodeFactory();
parser.setNodeFactory(factory);
NodeIterator itr = parser.elements();
processNodes(buf, itr, true);

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

/**
 * Extract all nodes matching the given filter.
 * @see Node#collectInto(NodeList, NodeFilter)
 * @param filter The filter to be applied to the nodes.
 * @throws ParserException If a parse error occurs.
 * @return A list of nodes matching the filter criteria,
 * i.e. for which the filter's accept method
 * returned <code>true</code>.
 */
public NodeList extractAllNodesThatMatch (NodeFilter filter)
  throws
    ParserException
{
  NodeIterator e;
  NodeList ret;
  ret = new NodeList ();
  for (e = elements (); e.hasMoreNodes (); )
    e.nextNode ().collectInto (ret, filter);
  return (ret);
}

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

/**
 * Extract all nodes matching the given filter.
 * @see Node#collectInto(NodeList, NodeFilter)
 * @param filter The filter to be applied to the nodes.
 * @throws ParserException If a parse error occurs.
 * @return A list of nodes matching the filter criteria,
 * i.e. for which the filter's accept method
 * returned <code>true</code>.
 */
public NodeList extractAllNodesThatMatch (NodeFilter filter)
  throws
    ParserException
{
  NodeIterator e;
  NodeList ret;
  ret = new NodeList ();
  for (e = elements (); e.hasMoreNodes (); )
    e.nextNode ().collectInto (ret, filter);
  return (ret);
}

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

for (NodeIterator e = mParser.elements (); e.hasMoreNodes (); )
for (NodeIterator e = mParser.elements (); e.hasMoreNodes (); )
  list.add (e.nextNode ());

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

for (NodeIterator iterator = mParser.elements (); iterator.hasMoreNodes (); )
  doSAX (iterator.nextNode ());
mContentHandler.endDocument ();

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

/**
 * Apply the given visitor to the current page.
 * The visitor is passed to the <code>accept()</code> method of each node
 * in the page in a depth first traversal. The visitor
 * <code>beginParsing()</code> method is called prior to processing the
 * page and <code>finishedParsing()</code> is called after the processing.
 * @param visitor The visitor to visit all nodes with.
 * @throws ParserException If a parse error occurs while traversing
 * the page with the visitor.
 */
public void visitAllNodesWith (NodeVisitor visitor) throws ParserException
{
  Node node;
  visitor.beginParsing();
  for (NodeIterator e = elements(); e.hasMoreNodes(); )
  {
    node = e.nextNode();
    node.accept(visitor);
  }
  visitor.finishedParsing();
}

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

/**
 * Apply the given visitor to the current page.
 * The visitor is passed to the <code>accept()</code> method of each node
 * in the page in a depth first traversal. The visitor
 * <code>beginParsing()</code> method is called prior to processing the
 * page and <code>finishedParsing()</code> is called after the processing.
 * @param visitor The visitor to visit all nodes with.
 * @throws ParserException If a parse error occurs while traversing
 * the page with the visitor.
 */
public void visitAllNodesWith (NodeVisitor visitor) throws ParserException
{
  Node node;
  visitor.beginParsing();
  for (NodeIterator e = elements(); e.hasMoreNodes(); )
  {
    node = e.nextNode();
    node.accept(visitor);
  }
  visitor.finishedParsing();
}

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

for (NodeIterator iterator = mParser.elements (); iterator.hasMoreNodes (); )
  doSAX (iterator.nextNode ());
mContentHandler.endDocument ();

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

for (NodeIterator iterator = mParser.elements ();
          iterator.hasMoreNodes ();
  doSAX (iterator.nextNode ()));

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

for (e = elements (); e.hasMoreNodes (); )

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

for (e = elements (); e.hasMoreNodes (); )

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

try
  for (NodeIterator iterator = parser.elements (); iterator.hasMoreNodes (); )
    list.add (iterator.nextNode ());
  for (NodeIterator iterator = parser.elements (); iterator.hasMoreNodes (); )
    list.add (iterator.nextNode ());

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

for (NodeIterator iterator = mParser.elements ();
          iterator.hasMoreNodes ();
  doSAX (iterator.nextNode ()));

相关文章