1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
public void AddXMLBooking (Hashtable<String,Booking> dataBooking) throws ParserConfigurationException, SAXException, IOException{
/** Etape 1 : récupération d'une instance de la classe "DocumentBuilderFactory" */
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try{
/** Etape 2 : création d'un parseur */
final DocumentBuilder builder = factory.newDocumentBuilder();
/** Etape 3 : création d'un Document */
final Document document = builder.parse(new File(XmlDoc));
// Element racine
Element racine = document.getDocumentElement();
Enumeration e = dataBooking.elements();
while (e.hasMoreElements()) {
// Début du corps
final Element customer = document.createElement("customer");
customer.setAttribute("id",e.nextElement()); // <--- LE PROBLEME EST ICI, IL ME DEMANDE DE CASTER EN STRING
customer.setAttribute("checkin",next.getCheckin());
customer.setAttribute("numberofnights",next.getNumberofnights());
racine.appendChild(customer);
/** Je ne met pas la suite car c'est la même chose */ |