Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!

S lakum

Greenhorn
+ Follow
since Jun 14, 2002
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by S lakum

Try going through my code where I used nextSibling() & had to experiment a lot before getting it right:
My DTD being:
<!ELEMENT root (sibling)+>
<!ELEMENT sibling (kid)>
<!ATTLIST sibling name CDATA #REQUIRED>
<!ELEMENT kid (#PCDATA)>
My Xml doc being:
<root>
<sibling name= "one">
<kid>hi1</kid>
</sibling>
<sibling name= "two">
<kid>hi2</kid>
</sibling>
<sibling name= "three">
<kid>hi3</kid>
</sibling>
<sibling name= "four">
<kid>hi4</kid>
</sibling>
</root>
My java code being:
NodeList sib = doc.getElementsByTagName("sibling");
int i =0;
for (Node child=sib.item(0); (child != null ); child = child.getNextSibling())
{
if(child.getNodeType()==child.ELEMENT_NODE)
{
System.out.println(child.getNodeName()+" = "+child.getAttributes().item(0).getNodeValue());
System.out.println(i+" "+child.getChildNodes().item(1).getChildNodes().item(0)+" "+i); i++;
}
}
My output is:
sibling = one
0 hi1 0
sibling = two
1 hi2 1
sibling = three
2 hi3 2
sibling = four
3 hi4 3

Hope this helps!
[ October 24, 2002: Message edited by: S lakum ]
[ October 24, 2002: Message edited by: S lakum ]
Hey Dan,
Thanx for the response.
What I'm trying to do is to read column-names from various tables. So, given a table-name, I just want it's column-names. That's why I'm searching for tagname 'table-name'
-sunitha
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
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
Hi,
HELP!!!
I went through all the possible help code from the net which tells me how to access the value/child of a tag.
But what I need is to access the column values for each table. There are several tables in this xml file. So, I search for the table name through getElementsByTagName(), then I need to parse for the column-names. I'm not able to make it work with getNextSibling().
<table-name>hist_client</table-name>
<data-element>
<column-name>camp_id</column-name>
<column-name>ccr_id</column-name>
<column-name>record_id</column-name>
<column-name>record_num</column-name>
</data-element>
-thanx
Hi all,
The multicast socket program below is quite straightfwd. The client sends a msg to a multicast group & the server displays it. My problem is the socket programs are not running on my home machine, but they run fine in my office. I'm behind no firewall. I'm running j2sdk1.4.0_01 version. I cant think why!!!
Can anyone plz help?
import java.io.*;
import java.net.*;
import java.util.*;
public class Server
{
public static void main(String [] arstring)
{
try
{
// Create a multicast datagram socket for receiving IP
// multicast packets. Join the multicast group at
// 230.0.0.1, port 7777.
MulticastSocket multicastSocket = new MulticastSocket(7777);
InetAddress inetAddress = InetAddress.getByName("230.0.0.1");
multicastSocket.joinGroup(inetAddress);
// Loop forever and receive messages from clients. Print
// the received messages.
while (true)
{
byte [] arb = new byte [100];
DatagramPacket datagramPacket = new DatagramPacket(arb, arb.length);
multicastSocket.receive(datagramPacket);
System.out.println(new String(arb));
}
}
catch (Exception exception)
{
exception.printStackTrace();
}
}
}
import java.io.*;
import java.net.*;
import java.util.*;
public class Client
{
public static void main(String [] arstring)
{
try
{
// Create a datagram package and send it to the multicast
// group at 230.0.0.1, port 7777.
byte [] arb = new byte [] {'h','e','l','l','o'};
InetAddress inetAddress = InetAddress.getByName("230.0.0.1");
DatagramPacket datagramPacket = new DatagramPacket(arb, arb.length, inetAddress, 7777);
MulticastSocket multicastSocket = new MulticastSocket();
multicastSocket.send(datagramPacket);
}
catch (Exception exception)
{
exception.printStackTrace();
}
}
}
Thanx
-sunitha
Hi,
I'm trying to access (from javascript) an applet's method which returns an array as follows:
<script language= 'JavaScript'>
var array1 = new Array(10);
array1 = appletname.methodname();
alert(array1[0]);
</script>
an 'undefined' is returned. I'm only having difficulty in the applet returning an array, not other data types.
I'm working on Internet Explorer.
Any help would be appreciated.
Thanks in advance.