• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

problem simply stated

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I just need to know how to move from node 'table-name' to node 'data-element', to node 'column-name'
My purpose here is to get the nodevalue of 'column-name' when i know the 'table-name' nodevalue(simply put- i need the column names of a table)
<table-name>hist_client</table-name>
<data-element>
<column-name>camp_id</column-name>
<column-name>ccl_id</column-name>
</data-element>
Help would be so appreciated!
Thanx
 
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please look at the below psuedo code to get an idea as to how to achieve your object using the DOM API.
I'm assuming that you have the <table-name> Node with you. The following is something what you need to do -
Node nextSibling = tableName.getNextSibling();
// make sure that this is an element node
if(nextSibling.getNodeType == nextSibling.ELEMENT_NODE)
{
if("data-element".equals(nextSibling.getNodeName())
{
// get the child nodes using getChildNodes()
// loop on the list of child nodes
// make sure that they are element nodes
// make sure their name is "column-name"
// AS SHOWN ABOVE
Node columnNameTextNode = columnNameElementNode.getFirstChild();
String wantedColumnName = columnNameTextNode.getNodeValue();
}
.........
..........
Please look at the following link for more details on the DOM spec.
http://java.sun.com/xml/jaxp/dist/1.1/docs/api/org/w3c/dom/package-summary.html
 
S lakum
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jayadev,
Thanks for ur help.
But I'm not able to work out the solution you've given. This is my DTD structure:
<!ELEMENT table-name (#PCDATA)>
<!ELEMENT data-element (column-name)+>
<!ELEMENT column-name (#PCDATA)>
when I'm comparing:
nextSibling.getNodeType==nextSibling.ELEMENT_NODE
i get the first as 1 and other as 3rd, ie text and element. Have I defined the dtd wrong?
Thanx
-sunitha
 
Evil is afoot. But this tiny ad is just an ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic