de.dbsystems.simplescrape
Class XMLHelper
java.lang.Object
de.dbsystems.simplescrape.XMLHelper
public class XMLHelper
- extends java.lang.Object
Class for holding HTML-comments. These are all texts surrounded by
- Since:
- 30.04.2007
- Author:
- Ronald Bieber, DB Systems GmbH
Method Summary |
static java.lang.String |
getAttribute(org.w3c.dom.Document document,
java.lang.String tagname,
java.lang.String attributename)
Returns the value of an attribute in the first element in a document with a given tag name. |
static java.lang.String |
getNodeContent(org.w3c.dom.Document document,
java.lang.String tagname)
Returns the text-content of the first element in a document with a given tag name. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
XMLHelper
public XMLHelper()
getNodeContent
public static java.lang.String getNodeContent(org.w3c.dom.Document document,
java.lang.String tagname)
- Returns the text-content of the first element in a document with a given tag name.
This is useful for well structured documents when it is known that there is only
one such element.
- Parameters:
document
- The document to search within.tagname
- The name of the element to retrieve.
- Returns:
- The text content of the element. Text nodes therein are appended for the result, but
no further descendants are included. If the element could not be found, the empty string is
returned.
getAttribute
public static java.lang.String getAttribute(org.w3c.dom.Document document,
java.lang.String tagname,
java.lang.String attributename)
- Returns the value of an attribute in the first element in a document with a given tag name.
This is useful for well structured documents when it is known that there is only
one such element and that it is has that attribute.
- Parameters:
document
- The document to search within.tagname
- The name of the element to access.attributename
- The attribute's name.
- Returns:
- The value of the attribute of the first respective element, or the empty string, if
the element of the attribute could not be found.