addElements

Element XmlWriter.addElements ( Element elementToAppendTo, String name, Hashtable subElements ) (enterprise edition only)
Element XmlWriter.addElements ( Element elementToAppendTo, String name, String text, Hashtable subElements ) (enterprise edition only)
Element XmlWriter.addElements ( Element elementToAppendTo, String name, String text, Hashtable attributes, Hashtable subElements ) (enterprise edition only)
Element XmlWriter.addElements ( String name, Hashtable subElements ) (enterprise edition only)
Element XmlWriter.addElements ( String name, String text, Hashtable subElements ) (enterprise edition only)
Element XmlWriter.addElements ( String name, String text, Hashtable attributes, Hashtable subElements ) (enterprise edition only)
void XmlWriter.addElements ( String containingTagName, DataSet dataSet ) (enterprise edition only)
void XmlWriter.addElements ( String containingTagName, String containingTagText, DataSet dataSet ) (enterprise edition only)
void XmlWriter.addElements ( String containingTagName, String containingTagText, Hashtable attributes, DataSet dataSet ) (enterprise edition only)

Description

Add multiple nodes under a single node (new or already in existence).

Parameters

  • elementToAppendTo The XmlElement to which the node is being appended.
  • name The element's name, as a string.
  • text (optional--pass in null to omit) Any text to be added inside of the node, as a string.
  • attributes (optional--pass in null to omit) Hashtable of attribute names and their associated values, for the node.
  • subElements (optional--pass in null to omit) Hashtable children nodes with node names as keys and text as values.

OR

  • name The element's name, as a string.
  • text (optional--pass in null to omit) Any text to be added inside of the node, as a string.
  • attributes (optional--pass in null to omit) Hashtable of attribute names and their associated values, for the node.
  • subElements (optional--pass in null to omit) Hashtable children nodes with node names as keys and text as values.

OR

  • containingTagName The element's name, as a string.
  • containingTagText (optional--pass in null to omit) Any text to be added inside of the containing node, as a string.
  • attributes (optional--pass in null to omit) Hashtable of attribute names and their associated values, for the node.
  • dataSet A dataSet object.

Return Values

Returns the main added element object, if one was created. It there was not a main element that was added then it returns void.

Change Log

Version Description
4.5 Available for enterprise edition.

Examples

Add Nodes to XML File

 // Import package
import com.screenscraper.xml.*;
 import java.util.Hashtable;

 // Create XmlWriter
 xmlWriter = new XmlWriter( "C:/students.xml", "students" );

 // Student Information
 info = new Hashtable();
 info.put("name", "John Smith");
 info.put("phone", "555-0135");
 info.put("gender", "male");

 // Add Student Node
 student = xmlWriter.addElements( "student", info );

 // Close XmlWriter
 xmlWriter.close();

See Also