Usar el xml

¿Cómo puedo crear un documento XML?

1 respuesta

Respuesta
1
Dentro de una clase con los atributos privados: pedidoid, estado, fecha y total;
y usando el xml parser de oracle version 2 (xmlparserv2.jar)
public Node toXML() {
XMLDocument doc = new XMLDocument();
Element pedido = doc.createElement("PEDIDO");
doc.appendChild(pedido);
Element pedidoid = doc.createElement("PEDIDOID");
pedidoid.appendChild(doc.createTextNode(this.idPedido.toString()));
pedido.appendChild(pedidoid);
Element fecha = doc.createElement("FECHAPEDIDO");
fecha.appendChild(doc.createTextNode(this.fecha.getFullDateString()));
pedido.appendChild(fecha);
Element total = doc.createElement("TOTAL");
total.appendChild(doc.createTextNode(this.total.toString()));
pedido.appendChild(total);
Element estado = doc.createElement("ESTADO");
estado.appendChild(doc.createTextNode(this.estado.toString()));
pedido.appendChild(estado);
return (Node)doc;
}

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas