eleonora 0 Light Poster

Hello,

I want to modify a java client/server game as to load the map from an xml and then validate against the dtd.

Is it okay to do something like that?

public void parseXML(){
		
		try{
			DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
			DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
			Document xmlDocument = dBuilder.parse(new FileInputStream("map.xml"));
			
			DOMSource source = new DOMSource(xmlDocument);
			

			StreamResult result = new StreamResult("map.xml");
			TransformerFactory tf = TransformerFactory.newInstance();
			Transformer transformer = tf.newTransformer();
			transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, "./map.dtd");
			


			transformer.transform(source, result);
 
		}
		catch(Exception e){
			e.printStackTrace();
		}
		
	}

Thanks in advance!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.