• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java HTMLMetaElement类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中org.w3c.dom.html.HTMLMetaElement的典型用法代码示例。如果您正苦于以下问题:Java HTMLMetaElement类的具体用法?Java HTMLMetaElement怎么用?Java HTMLMetaElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

HTMLMetaElement类属于org.w3c.dom.html包,在下文中一共展示了HTMLMetaElement类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getHtmlMeta

点赞 2

import org.w3c.dom.html.HTMLMetaElement; //导入依赖的package包/类
public String getHtmlMeta(String input) throws YadisException
{
    String xrdsLocation = null;

    HTMLDocumentImpl doc = this.parseDocument(input);
    if (DEBUG)
    {
        try
        {
            _log.debug("document:\n" + OpenID4JavaDOMParser.toXmlString(doc));
        } catch (TransformerException e)
        {
            _log.debug("An exception occurs while transforming the document to string in debugging.", e);
        }
    }

    NodeList heads = doc.getElementsByTagName("head");
    if (heads.getLength() != 1)
        throw new YadisException(
                "HTML response must have exactly one HEAD element, "
                        + "found " + heads.getLength() + " : "
                        + heads.toString(),
                OpenIDException.YADIS_HTMLMETA_INVALID_RESPONSE);

    HTMLHeadElement head = (HTMLHeadElement) doc.getHead();
    NodeList metaElements = head.getElementsByTagName("META");
    if (metaElements == null || metaElements.getLength() == 0)
    {
        if (DEBUG)
            _log.debug("No <meta> element found under <html><head>. " +
            "See Yadis specification, section 6.2.5/1.");
    }
    else
    {
        for (int i = 0, len = metaElements.getLength(); i < len; i++)
        {
            HTMLMetaElement metaElement = (HTMLMetaElement) metaElements.item(i);

            String httpEquiv = metaElement.getHttpEquiv();
            if (YadisResolver.YADIS_XRDS_LOCATION.equalsIgnoreCase(httpEquiv))
            {
                if (xrdsLocation != null)
                    throw new YadisException(
                        "More than one "
                            + YadisResolver.YADIS_XRDS_LOCATION
                            + "META tags found in HEAD: "
                            + head.toString(),
                        OpenIDException.YADIS_HTMLMETA_INVALID_RESPONSE);

                xrdsLocation = metaElement.getContent();
                if (DEBUG)
                    _log.debug("Found " + YadisResolver.YADIS_XRDS_LOCATION
                        + " META tags.");
            }
        }
    }
    return xrdsLocation;
}
 

开发者ID:jbufu,
项目名称:openid4java
代码行数:59,
代码来源:CyberNekoDOMYadisHtmlParser.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)