Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > DOM PARSER

Reply
Thread Tools

DOM PARSER

 
 
Sukanta
Guest
Posts: n/a
 
      11-22-2004
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
 
Reply With Quote
 
 
 
 
Piet
Guest
Posts: n/a
 
      12-05-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) (Sukanta) wrote in message news:<(E-Mail Removed). 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replacing _xmlplus.dom.minidom with xml.dom.minidom aine_canby@yahoo.com Python 3 08-03-2007 03:50 PM
Convert a XML DOM Object to a HTML DOM Object manjunath.d@gmail.com XML 0 09-20-2005 08:16 AM
What is the difference between DOM Level 1 and DOM Level 2. mike XML 1 11-20-2004 03:19 PM
Difference between pure DOM and JAXP over DOM ?? Thorsten Meininger XML 0 07-28-2004 08:51 AM
Difference between pure DOM and JAXP over DOM ?? Thorsten Meininger Java 0 07-28-2004 08:51 AM



Advertisments