|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.edustructures.util.XMLUtils
public class XMLUtils
Various static helper routines for manipulating DOM Documents.
| Constructor Summary | |
|---|---|
XMLUtils()
|
|
| Method Summary | |
|---|---|
static java.lang.String |
getAttribute(org.w3c.dom.Node node,
java.lang.String attr)
Gets a named attribute of a Node |
static java.lang.String |
getElementAttribute(org.w3c.dom.Node node,
java.lang.String element,
java.lang.String attribute,
java.lang.String defaultValue)
A convenience function to get the named attribute of a child element. |
static org.w3c.dom.Node |
getElementByAttr(org.w3c.dom.Node node,
java.lang.String element,
java.lang.String attribute,
java.lang.String value)
Gets the first child element with the specified tag name having an attribute set to the specified value. |
static java.util.List<org.w3c.dom.Node> |
getElementsByTagName(org.w3c.dom.Node node,
java.lang.String element,
boolean filter)
Gets all child elements with the specified tag name, optionally excluding those elements that have an enabled attribute set to false. |
static java.lang.String |
getElementTextValue(org.w3c.dom.Document doc,
java.lang.String element)
Returns the text value of the first element in the document with the specified tag name |
static java.lang.String |
getElementTextValue(org.w3c.dom.Node node,
java.lang.String element)
Returns the text value of the first child element found with the specified tag name. |
static org.w3c.dom.Node |
getFirstElementIgnoreCase(org.w3c.dom.Node node,
java.lang.String element)
Returns the first child element found with the specified tag name |
static org.w3c.dom.Node |
getFirstElementWithTagName(org.w3c.dom.Node node,
java.lang.String element)
Returns the first child element found with the specified tag name |
static java.lang.String |
getText(org.w3c.dom.Node n)
Gets the text for a node by concatenating child TEXT elements. |
static void |
removeAttribute(org.w3c.dom.Node node,
java.lang.String attr)
Removes a named attribute of a Node |
static void |
setAttribute(org.w3c.dom.Node node,
java.lang.String attr,
java.lang.String value)
Sets a named attribute of a Node |
static void |
setElementAttribute(org.w3c.dom.Node node,
java.lang.String element,
java.lang.String attribute,
java.lang.String value)
A convenience function to set the named attribute of a child element. |
static void |
setOrRemoveAttribute(org.w3c.dom.Element element,
java.lang.String attr,
java.lang.String value)
Sets a named attribute of an Element, or removes the attribute if the value is null; |
static void |
setOrRemoveAttribute(org.w3c.dom.Node node,
java.lang.String attr,
java.lang.String value)
Sets a named attribute of a Node, or removes the attribute if the value is null; |
static void |
setText(org.w3c.dom.Node n,
java.lang.String text)
Sets the text for a node |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public XMLUtils()
| Method Detail |
|---|
public static java.lang.String getText(org.w3c.dom.Node n)
public static void setText(org.w3c.dom.Node n,
java.lang.String text)
public static java.lang.String getAttribute(org.w3c.dom.Node node,
java.lang.String attr)
node - The node to searchattr - The name of the attribute to get
public static void setAttribute(org.w3c.dom.Node node,
java.lang.String attr,
java.lang.String value)
node - The nodeattr - The name of the attribute to setvalue - The value to assign to the attribute
public static void setOrRemoveAttribute(org.w3c.dom.Node node,
java.lang.String attr,
java.lang.String value)
node - The node to searchattr - The name of the attribute to set or removevalue - The value to assign, or NULL to remove
public static void setOrRemoveAttribute(org.w3c.dom.Element element,
java.lang.String attr,
java.lang.String value)
element - The element to searchattr - The name of the attribute to set or removevalue - The value to assign, or NULL to remove
public static void removeAttribute(org.w3c.dom.Node node,
java.lang.String attr)
node - The node to searchattr - The name of the attribute to remove
public static java.lang.String getElementTextValue(org.w3c.dom.Node node,
java.lang.String element)
node - The node to searchelement - The element tag name to search for
public static java.lang.String getElementTextValue(org.w3c.dom.Document doc,
java.lang.String element)
doc - The Document to searchelement - The element tag name to search for
public static org.w3c.dom.Node getFirstElementWithTagName(org.w3c.dom.Node node,
java.lang.String element)
node - The node to searchelement - The element tag name to search for
public static org.w3c.dom.Node getFirstElementIgnoreCase(org.w3c.dom.Node node,
java.lang.String element)
node - The node to searchelement - The element tag name to search for
public static java.util.List<org.w3c.dom.Node> getElementsByTagName(org.w3c.dom.Node node,
java.lang.String element,
boolean filter)
enabled attribute set to false.
node - The parent nodeelement - The element tag namefilter - Do not return elements that have the enabled attribute set to false
public static org.w3c.dom.Node getElementByAttr(org.w3c.dom.Node node,
java.lang.String element,
java.lang.String attribute,
java.lang.String value)
node - The parent nodeelement - The element tag nameattribute - The attribute namevalue - The attribute value to match
public static java.lang.String getElementAttribute(org.w3c.dom.Node node,
java.lang.String element,
java.lang.String attribute,
java.lang.String defaultValue)
This method searches the specified Node for the first matching element, then returns the value of the named attribute. If the attribute does not exist the default value is returned.
node - The node to searchelement - The tag name of the element to search (it must be a non-
repeating child of the node)attribute - The name of the attributedefaultValue - The value to return if the property is not found
public static void setElementAttribute(org.w3c.dom.Node node,
java.lang.String element,
java.lang.String attribute,
java.lang.String value)
This method searches the specified Node for the first matching element, then sets the value of the named attribute. If the element does not exist, no action is taken.
node - The node to searchelement - The tag name of the element to search (it must be a non-
repeating child of the node)attribute - The name of the attributevalue - The value of the attribute
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||