Code example for Document

Methods: createElement, createTextNode

0
		doc = parser.newDocument();
 
	} 
 
	Node getField(String fieldName, String fieldValue) {
		Node field = doc.createElement(fieldName);
		field.appendChild(doc.createTextNode(fieldValue));
		return field;
	} 
 
	/** 
	 * @param place  Participant's final place in competition 
	 * @param record Participant's Record 
	 */ 
	@Override 
	public void writeNext(Place place, Record record) {
 
		Format format = new SimpleDateFormat("dd.MM.yyyy");
 
		Node athlete = doc.createElement("athlete");
		competition.appendChild(athlete);
 
		Participant participant = record.getParticipant();
		athlete.appendChild(getField("place", place.getFinalPlace()));
		athlete.appendChild(getField("score", String.valueOf(record.getTotalPoints())));