substituting blank spaces with hyphen and generating a tree

P

Prasad

This was our earlier design

<Product Inventory Info>
<Company>
<Make>Computer General</Make>
<Model>Wizbang 1900</Model>

It was later found that <Product Inventory Info> had spaces in
between. It was later decided that it has to be of the following
format

<Product-Inventory-Info nodeName="Product Inventory Info">
<Company nodeName="Company">
<Make nodeName="Make" nodeValue="Computer General" />

These tags are virtual tags created. I need to parse irt and generate
a dom tree based on attributes nodename ane nodevalue as the tags are
virtual tags which are created dynamically to avoid the empty spaces.


How should I do this?
 
J

Joe Kesselman

Prasad said:
These tags are virtual tags created. I need to parse irt and generate
a dom tree based on attributes nodename ane nodevalue as the tags are
virtual tags which are created dynamically to avoid the empty spaces.

I'm really not sure what you're asking here. If you run the document
through any standard XML parser with DOM output, you'll get a DOM tree
with the attributes. You can't have DOM node names with spaces in them
any more than you can have XML element or attribute names with spaces in
them, but the attribute values will be available in the DOM tree and
your program should be able to look at them (or look at the node names
with the dashes) and do the right things.

What are you trying to do, how are you trying to do it, what are you
getting and what do you want to get instead? Unless we understand what
problem you are trying to solve, we can't help you solve it.
 
P

Prasad

I'm really not sure what you're asking here. If you run the document
through any standard XML parser with DOM output, you'll get a DOM tree
with the attributes. You can't have DOM node names with spaces in them
any more than you can have XML element or attribute names with spaces in
them, but the attribute values will be available in the DOM tree and
your program should be able to look at them (or look at the node names
with the dashes) and do the right things.

What are you trying to do, how are you trying to do it, what are you
getting and what do you want to get instead? Unless we understand what
problem you are trying to solve, we can't help you solve it.

I need to display a tree structure on the applet with nodename and
nodevalue. As in regular XML the tag name becomes the nodename here
the tag is virtual so I was thinking to assign the value of nodename
attribute as the node name of the tree. The tree has to be displayed
on the GUI which is an applet. So I am generating a dom tree out of
xml and then transferring this data to the tree object that needs to
be displayed on the screen.
 
P

Prasad

I need to display a tree structure on the applet with nodename and
nodevalue. As in regular XML the tag name becomes the nodename here
the tag is virtual so I was thinking to assign the value of nodename
attribute as the node name of the tree. The tree has to be displayed
on the GUI which is an applet. So I am generating a dom tree out of
xml and then transferring this data to the tree object that needs to
be displayed on the screen.

Could you tell me how I retrive the attributed from the node of a DOM
tree. Thanks in advance
 
P

Prasad

I'm really not sure what you're asking here. If you run the document
through any standard XML parser with DOM output, you'll get a DOM tree
with the attributes. You can't have DOM node names with spaces in them
any more than you can have XML element or attribute names with spaces in
them, but the attribute values will be available in the DOM tree and
your program should be able to look at them (or look at the node names
with the dashes) and do the right things.

What are you trying to do, how are you trying to do it, what are you
getting and what do you want to get instead? Unless we understand what
problem you are trying to solve, we can't help you solve it.

Could you also tell me how I should retrice the attributes of an xml
file from the node of a DOM tree. Thanks in advance.
 
J

Joe Kesselman

I need to display a tree structure on the applet with nodename and
nodevalue. As in regular XML the tag name becomes the nodename here
the tag is virtual so I was thinking to assign the value of nodename
attribute as the node name of the tree. The tree has to be displayed
on the GUI which is an applet. So I am generating a dom tree out of
xml and then transferring this data to the tree object that needs to
be displayed on the screen.

OK, so the XML part of it is straight XML, and the data transfer and
tree is straight applet coding. What's the question?
 
J

Joe Kesselman

Could you tell me how I retrive the attributed from the node of a DOM
tree. Thanks in advance

Node.getAttributes().

Or, to retrieve a specific attribute by name, Element.getAttributeNS, or
Element.getAttributeNodeNS (the old non-NS versions of these are
effectively deprecated).

Any halfway-adequate DOM tutorial should show you how to do this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top