org.apache.tools.ant.util
Class DOMUtils
java.lang.Object
org.apache.tools.ant.util.DOMUtils
public class DOMUtils
extends java.lang.Object
Some utility methods for common tasks when building DOM trees in memory.
In this documentation
<a>
means an
Element
instance with name
a
.
static void | appendCDATA(Element parent, String content) - Adds a nested CDATA section.
|
static void | appendCDATAElement(Element parent, String name, String content) - Adds a nested CDATA section in a new child element.
|
static void | appendText(Element parent, String content) - Adds nested text.
|
static void | appendTextElement(Element parent, String name, String content) - Adds nested text in a new child element.
|
static Element | createChildElement(Element parent, String name) - Creates a named Element and appends it to the given element,
returns it.
|
static Document | newDocument() - Get a new Document instance,
|
appendCDATA
public static void appendCDATA(Element parent,
String content)
Adds a nested CDATA section.
This means
appendCDATA(<a>, "b")
creates
<a><[!CDATA[b]]></a>
parent
- element that will receive the new element as child.content
- text content.
appendCDATAElement
public static void appendCDATAElement(Element parent,
String name,
String content)
Adds a nested CDATA section in a new child element.
This means
appendCDATAElement(<a>, "b", "c")
creates
<a>
<b><![CDATA[c]]></b>
</a>
parent
- element that will receive the new element as child.name
- of the child element.content
- text content.
appendText
public static void appendText(Element parent,
String content)
Adds nested text.
This means
appendText(<a>, "b")
creates
<a>b</a>
parent
- element that will receive the new element as child.content
- text content.
appendTextElement
public static void appendTextElement(Element parent,
String name,
String content)
Adds nested text in a new child element.
This means
appendTextElement(<a>, "b", "c")
creates
<a>
<b>c</b>
</a>
parent
- element that will receive the new element as child.name
- of the child element.content
- text content.
createChildElement
public static Element createChildElement(Element parent,
String name)
Creates a named Element and appends it to the given element,
returns it.
This means
createChildElement(<a>, "b")
creates
<a>
<b/>
</a>
and returns
<b>
.
parent
- element that will receive the new element as child.name
- name of the new element.
newDocument
public static Document newDocument()
Get a new Document instance,