Can’t add Element to XML DOM JAVA

Not sure if you need more code, i can’t seem to add the child elements…

What i want is:

<ParkingSpot>
<Vehicle>
<LicensePlate>ABC 123</LicensePlate>
<Park startTime = "d.toString()"></Park>
</Vehicle>
</ParkingSpot>

Code:

vehicle = null;
vehicle= document.createElement("Vehicle");

Element licensePlate = document.createElement("LicensePlate");
licensePlate.appendChild(document.createTextNode("ABC 123"));

Element park = document.createElement("Park");

Date d = new Date();
park.setAttribute("startTime", d.toString());

vehicle.appendChild(licensePlate);
vehicle.appendChild(park);
parkingSpot.appendChild(vehicle);

Am I doing something wrong? Also parkingSpot is an existing element Node on my XML file, i checked that previously on the code.


Download cant.add.element.to.xml.dom.java.zip
Direct Link


Download


Download cant.add.element.to.xml.dom.java.zip
Mediafire


Download


Download cant.add.element.to.xml.dom.java.zip
RapidShare


Download


Download cant.add.element.to.xml.dom.java.zip
Fileinz


Download


Download cant.add.element.to.xml.dom.java.zip
Ryushare


Download

Both comments and pings are currently closed.

Comments are closed.