Quote:
quote:Originally posted by umeshayk
Please Help me related to this
Is it possible too create a treestructure which will be pick from the xml file.
Please reply me back
Please send me code
Regards
Umesha Y.K
|
Yes of course. You can use JAXP:
Code:
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.Document;
import java.io.File;
public class ParseXML {
public static void main(String[] args)
{
if(args.length != 1 || args[0] == null || args[0].trim().equals("")) {
System.out.println("Invalid argument!");
System.exit(1);
}
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
// we suppose that the URI of the XML document is in the args[0]
Document xmlDocument = db.parse(new File(args[0]));
// variable xmlDocument contains the DOM tree (the root node)
// process the DOM tree here
// ...
}
catch (Exception e) {
e.printStackTrace();
}
}
}
Regards,
Armen