Java XML Element Get by Name getElementByTag(HTMLDocument htmlDoc, int offset, Tag tag)

Here you can find the source of getElementByTag(HTMLDocument htmlDoc, int offset, Tag tag)

Description

get Element By Tag

License

LGPL

Declaration

public static Element getElementByTag(HTMLDocument htmlDoc, int offset, Tag tag) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import javax.swing.text.Element;

import javax.swing.text.StyleConstants;

import javax.swing.text.html.HTML.Tag;
import javax.swing.text.html.HTMLDocument;

public class Main {
    public static Element getElementByTag(HTMLDocument htmlDoc, int offset, Tag tag) {

        Element e = htmlDoc.getCharacterElement(offset);
        while (e != null && !e.getAttributes().containsAttribute(StyleConstants.NameAttribute, tag)) {
            e = e.getParentElement();//w  ww.j  a v a2 s  . c  o  m
        }

        return e;
    }
}

Related

  1. getElement(String elementName, Element parentElement)
  2. getElement(String name, int index, Element parent)
  3. getElementByName(Document document, String name)
  4. getElementByName(Element eParent, String elementName)
  5. getElementByName(Element parent, String nodeName)
  6. getElementByTagAndName(Document document, String tagName, String elementName)
  7. getElementByTagName(Document doc, String eleName)
  8. getElementByTagName(Document document, String tagName)
  9. getElementByTagName(Element aParent, String aName)