Logo Search packages:      
Sourcecode: icedtea-web version File versions  Download package

net::sourceforge::nanoxml::XMLElement Class Reference

List of all members.


Detailed Description

XMLElement is a representation of an XML object. The object is able to parse XML code.

Parsing XML Data
You can parse XML data using the following code:
XMLElement xml = new XMLElement();
FileReader reader = new FileReader("filename.xml");
xml.parseFromReader(reader);
Retrieving Attributes
You can enumerate the attributes of an element using the method enumerateAttributeNames. The attribute values can be retrieved using the method getStringAttribute. The following example shows how to list the attributes of an element:
XMLElement element = ...;
Enumeration enum = element.getAttributeNames();
while (enum.hasMoreElements()) {
    String key = (String) enum.nextElement();
    String value = element.getStringAttribute(key);
    System.out.println(key + " = " + value);
}
Retrieving Child Elements
You can enumerate the children of an element using enumerateChildren. The number of child elements can be retrieved using countChildren.
Elements Containing Character Data
If an elements contains character data, like in the following example:
<title>The Title</title> you can retrieve that data using the method getContent.
Subclassing XMLElement
When subclassing XMLElement, you need to override the method createAnotherElement which has to return a new copy of the receiver.

See also:
net.sourceforge.nanoxml.XMLParseException
Author:
Marc De Scheemaecker <cyberelf@mac.com>
Version:
Name
,
Revision
1.2

Definition at line 97 of file XMLElement.java.


Public Member Functions

void addChild (XMLElement child)
int countChildren ()
Enumeration enumerateAttributeNames ()
Enumeration enumerateChildren ()
Object getAttribute (String name)
String getContent ()
int getLineNr ()
String getName ()
void parseFromReader (Reader reader, int startingLineNr) throws IOException, XMLParseException
void parseFromReader (Reader reader) throws IOException, XMLParseException
void sanitizeInput (InputStreamReader isr, PipedOutputStream pout)
void setAttribute (String name, Object value)
void setContent (String content)
void setName (String name)
 XMLElement ()

Protected Member Functions

boolean checkCDATA (StringBuffer buf) throws IOException
boolean checkLiteral (String literal) throws IOException
XMLElement createAnotherElement ()
XMLParseException expectedInput (String charSet, char ch)
XMLParseException expectedInput (String charSet)
XMLParseException invalidValue (String name, String value)
XMLParseException invalidValueSet (String name)
char readChar () throws IOException
void resolveEntity (StringBuffer buf) throws IOException
void scanElement (XMLElement elt) throws IOException
void scanIdentifier (StringBuffer result) throws IOException
void scanPCData (StringBuffer data) throws IOException
void scanString (StringBuffer string) throws IOException
char scanWhitespace (StringBuffer result) throws IOException
char scanWhitespace () throws IOException
void skipComment () throws IOException
void skipSpecialTag (int bracketLevel) throws IOException
XMLParseException syntaxError (String context)
XMLParseException unexpectedEndOfData ()
XMLParseException unknownEntity (String name)
void unreadChar (char ch)
 XMLElement (Hashtable entities, boolean skipLeadingWhitespace, boolean fillBasicConversionTable, boolean ignoreCase)

Private Attributes

Hashtable attributes
char charReadTooMuch
Vector children
String contents
Hashtable entities
boolean ignoreCase
boolean ignoreWhitespace
int lineNr
String name
int parserLineNr
Reader reader
char sanitizeCharReadTooMuch

The documentation for this class was generated from the following file:

Generated by  Doxygen 1.6.0   Back to index