I wanted to know how to retrieve the DTD file name from the parsed XML file. But your code will help me in a the future.
In fact, what I wanted is :
doc.getDoctype().getSystemId();
I haven't seen this before because I was thinking about something like:
doc.getSystemId();
Thanks for your help. anthony
K. Venugopal wrote:
Hi Anthony,
An example on how to set doctype when i am creating an xml file.Does this help .
public class DOMGenerate {
public static void main( String[] argv ) {
try {
Document doc= new DocumentImpl();
Element root = doc.createElement("person"); // Create Root Element
Element item = doc.createElement("name"); // Create element
item.appendChild( doc.createTextNode("Jeff") );
root.appendChild( item ); // atach element to Root element
item = doc.createElement("age"); // Create another Element
item.appendChild( doc.createTextNode("28" ) );
root.appendChild( item ); // Attach Element to previous element down tree
item = doc.createElement("height"); item.appendChild( doc.createTextNode("1.80" ) );
root.appendChild( item ); // Attach another Element - grandaugther
doc.appendChild( root ); // Add Root to Document
OutputFormat format = new OutputFormat( doc ); //Serialize DOM
format.setDoctype("personnel","personal.dtd");
StringWriter stringOut = new StringWriter(); //Writer will be a String XMLSerializer serial = new XMLSerializer( stringOut, format );
serial.asDOMSerializer(); // As a DOM Serializer
serial.serialize( doc.getDocumentElement() ); System.out.println( "STRXML = " + stringOut.toString() ); //Spit out DOM as a String } catch ( Exception ex ) {
ex.printStackTrace();
}
} } Regards
venu
Anthony Saucet wrote:
I'm using xerces4.0.7 to parse(DOM parser) an xml file against a dtd, and then build a DOM tree.
I would like to get the dtd file name included in the xml file. How can I do that?
many thanks
anthony
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
