public final class XmlElement extends Object
Modifier and Type | Method and Description |
---|---|
void |
addChild(XmlElement child) |
String |
attribute(String name)
Returns an attribute of the element.
|
String |
attribute(String name,
String defaultValue)
Returns an attribute of the element.
|
Set<String> |
attributeNames() |
XmlElement |
child(int index) |
XmlElement |
child(String... names) |
List<XmlElement> |
children() |
List<XmlElement> |
childrenWithName(String name) |
String |
content()
Returns the PCDATA content of the object.
|
String |
content(String... names) |
int |
countChildren() |
XmlElement |
firstChild() |
boolean |
hasChildren() |
int |
lineNumber()
Returns the line nr in the source data on which the element is found.
|
String |
name()
Returns the name of the element.
|
static XmlElement |
parse(Reader reader) |
static XmlElement |
parse(Reader reader,
boolean ignoreLeadingAndTrailingWhitespace) |
static XmlElement |
parse(String string) |
static XmlElement |
parse(String string,
boolean ignoreLeadingAndTrailingWhitespace) |
String |
toString() |
void |
write(Writer writer) |
public void addChild(XmlElement child)
public int countChildren()
public boolean hasChildren()
public List<XmlElement> children()
public List<XmlElement> childrenWithName(String name)
public XmlElement firstChild()
public XmlElement child(int index)
public XmlElement child(String... names)
public String content()
null
is returned.public int lineNumber()
0
there is no associated source data.public String attribute(String name)
null
is returned.name
- The name of the attribute.public String attribute(String name, String defaultValue)
defaultValue
is returned.name
- The name of the attribute.defaultValue
- Key to use if the attribute is missing.public String name()
public static XmlElement parse(Reader reader) throws XmlParseException, IOException
XmlParseException
IOException
public static XmlElement parse(Reader reader, boolean ignoreLeadingAndTrailingWhitespace) throws IOException, XmlParseException
IOException
XmlParseException
public static XmlElement parse(String string) throws XmlParseException
XmlParseException
public static XmlElement parse(String string, boolean ignoreLeadingAndTrailingWhitespace) throws XmlParseException
XmlParseException
public void write(Writer writer) throws IOException
IOException
Copyright © 2021–2024. All rights reserved.