By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,760 Members | 969 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,760 IT Pros & Developers. It's quick & easy.

DOM PARSER

P: n/a
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.

<?xml version="1.0" encoding="UTF-8"?>
<Platformlist>
<Platform Name="A90-610010" type="xyz" customer="HSS">
<Feature Name="LAN Configuration"/>
<Feature Name="WAN Configuration"/>
<Feature Name="Firewal Settings"/>
</Platform>
<Platform Name="B90-600085" type="xyz" customer="HSS">
<Feature Name="Firewall Settings"/>
<Feature Name="WAN Configuration"/>
</Platform>
<Platform Name="C90-610010" type="xyz" customer="HSS">
<Feature Name="Firewall Settings"/>
<Feature Name="WAN Settings"/>
</Platform>
</Platformlist>

Thanks in advance.

Sukanta
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.