addElement
Element XmlWriter.addElement ( String name ) (enterprise edition only)
Element XmlWriter.addElement ( String name, String text ) (enterprise edition only)
Element XmlWriter.addElement ( String name, String text, Hashtable attributes ) (enterprise edition only)
Element XmlWriter.addElement ( Element elementToAppendTo, String name ) (enterprise edition only)
Element XmlWriter.addElement ( Element elementToAppendTo, String name, String text ) (enterprise edition only)
Element XmlWriter.addElement ( Element elementToAppendTo, String name, String text, Hashtable attributes ) (enterprise edition only)
Description
Add a node to the XML file.
Parameters
- elementToAppendTo (optional) The XmlElement to which the node is being appended.
- name The element's name, as a string.
- text (optional) Any text to be added inside of the node, as a string.
- attributes (optional) Hashtable of attribute names and their associated values, for the node.
Return Values
Returns the added element object.
Change Log
Version |
Description |
4.5 |
Available for enterprise edition. |
Examples
Add Nodes to XML File
// Import package
import com.screenscraper.xml.*;
// Create XmlWriter
xmlWriter = new XmlWriter( "C:/students.xml", "students" );
// Add Student Node
student = xmlWriter.addElement( "student" );
// Add Name Node Under the Student
address = xmlWriter.addElement( student, "name", "John Smith" );
// Close XmlWriter
xmlWriter.close();
See Also
- addElements() [XmlWriter] - Add multiple nodes under a single node