sm********@hss.hns.com (Sukanta) wrote in message news:<5c**************************@posting.google. com>...
Hi,
Below is my XML file with some Platform and feature name. I have to
show the platform name in a drop down list.
How I will write a DOM parser for this.
Hello Sukanta,
parsing an Xml document (i. e. transforming the stream of bytes into a
tree-like structure) is one thing, but displaying the information in
some GUI is an entirely different thing. Its implementation will
strongly depend on the programming language that you want to use.
Some pseudo-code in Java will look like this. In this example, it is
assumed that apache Xalan is in the classpath, because it is used as a
source for the xpath engine. You may also want to use JAXP 1.3 (part
of Java 1.5).
Document dom = DocumentBuilderFactory.newInstance().newDocumentBu ilder().parse("PathToXmlFile.xml");
Node root = dom.getDocumentElement();
NodeList nodes = XPathAPI.selectNodeList(root,"Platform");
JComboBox box = new JComboBox();
for (int i=0;i<nodes.getLength();i++){
box.addItem(nodes.item(i).attributes.getNamedItem( "Name").getNodeValue())
}
That should generate a JComboBox in which your "Platform"-Nodes are
represented by their "Name"-attribute.
BW
Piet